Description

There are two octal integers numbers a and b.You need to calculate the result of a minus b,then output in octal notation.

If the result is negative, you should use the negative sign instead of complement notation.

Input

The first line is an integer T(1 <= T <= 1000), indicating the number of test cases.

For each case, the first and only line contains two octal integers a, b. (0 <= a, b < 2^100).

Output

Print the result contains a list of the fully qualified octal digits,one per line.

Sample Input

176 7

Sample Output

67

Hint

        就是给你两个八进制数~让你进行减法,并以八进制的形式输出。思路不难~~但一定要小心各个地方的坑;

        顺便提供一组数据( 1   2000  1);

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int m[1005];
#define mm 1000
int main()
{
	int te;
	scanf("%d", &te);
	string j, k;
	char q[1005], p[1005];
	int spot;
	while (te--)
	{
		spot = 1;
		memset(m, 0, sizeof(m));
		memset(q, 0, sizeof(q));
		memset(p, 0, sizeof(p));
		cin >> j >> k;
		int len1 = j.length();
		int len2 = k.length();
		int cnt = len1 - 1;
		for (int s = mm; s > mm - len1; s--)
		{
			q[s] = j[cnt--];
		}
		cnt = len2 - 1;
		for (int s = mm; s > mm - len2; s--)
		{
			p[s] = k[cnt--];
		}
		if (len1 > len2)
		{
			for (int s = mm; s > mm - len2; s--)
			{
				int w = q[s] - p[s];
				if (w < 0)
				{
					w += 8;
					q[s - 1] = q[s - 1] - 1;
				}
				m[s] = w;
			}
			for (int s = mm - len2; s > mm - len1; s--)
			{
				int t = q[s] - '0';
				if (t < 0)
				{
					t += 8;
					q[s - 1]--;
				}
				m[s] = t;
			}
		}
		else if (len1 == len2)
		{
			int sp = 1;
			for (int s = mm - len1 + 1; s <= mm; s++)
			{
				if (q[s] > p[s])
				{
					break;
				}
				if (q[s] < p[s])
				{
					sp = 0;
					break;
				}
			}
			if (sp)
			{
				for (int s = mm; s > mm - len2; s--)
				{
					int w = q[s] - p[s];
					if (w < 0)
					{
						w += 8;
						q[s - 1] = q[s - 1] - 1;
					}
					m[s] = w;
				}
			}
			else
			{
				//	cout << "asdasd" << endl;
				spot = 0;
				for (int s = mm; s > mm - len2; s--)
				{
					int w = p[s] - q[s];
					if (w < 0)
					{
						w += 8;
						p[s - 1]--;
					}
					m[s] = w;
				}
			}
		}
		else
		{
			spot = 0;
			for (int s = mm; s > mm - len1; s--)
			{
				int w = p[s] - q[s];
				if (w < 0)
				{
					w += 8;
					p[s - 1]--;
				}
				m[s] = w;
			}
			for (int s = mm - len1; s > mm - len2; s--)
			{
				int t = p[s] - '0';
				if (t < 0)
				{
					t += 8;
					p[s - 1]--;
				}
				m[s] = t;
			}
		}
		if (!spot)
		{
			cout << "-";
		}
		int sp = 0;
		for (int s = 0; s < mm; s++)
		{
			if (m[s] != 0)
			{
				sp = 1;
			}
			if (sp)
				cout << m[s];
		}
		cout << m[mm] << endl;
	}
	return 0;
}