ayit609 第八周周赛的f题

You are given two positive integers aa and bb. In one move you can increase aa by 11 (replace aa with a+1a+1). Your task is to find the minimum number of moves you need to do in order to make aa divisible by bb. It is possible, that you have to make 00 moves, as aa is already divisible by bb. You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤1041≤t≤104) — the number of test cases. Then tt test cases follow.

The only line of the test case contains two integers aa and bb (1≤a,b≤1091≤a,b≤109).

Output

For each test case print the answer — the minimum number of moves you need to do in order to make aadivisible by bb.

Example

Input

5
10 4
13 9
100 13
123 456
92 46

Output

2
5
4
333
0
#include
#include
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int m,n;
		scanf("%d %d",&m,&n);
		int s,r;
		if(m%n==0)
		printf("0\n");
		else
		{
			s=m/n+1;
			r=n*s-m;	
			printf("%d\n",r);		
		}
	}
	return 0;
}

   题意  首先给你一个k,是多少测试数据,接着就有k组数据 判断a是否能被b整除,如果不能,只能找比a大且是与a差值        最小的数,它们的差就是步数。

思路     a是否能被b整除,能得话就输出0,不能得话找到a/b+1,这就是大于a且能被b整除的数,(a/b+1)*b-a即为所求

你可能感兴趣的:(ayit609 第八周周赛的f题)