A. Divisibility Problem

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 aa divisible by bb.

Example

input

Copy

5
10 4
13 9
100 13
123 456
92 46

output

Copy

2
5
4
333
0

 

解题说明:数字题,求解即可。

#include
#include
#include
#include
#include

using namespace std;

int main() 
{
	int a, t, b, c;
	scanf("%d", &t);
	while (t--) 
	{
		scanf("%d%d", &a, &b);
		a = a % b;
		if (a == 0)
		{
			printf("0\n");
		}
		else
		{
			printf("%d\n", b - a);
		}
	}
	return 0;
}

 

你可能感兴趣的:(AC路漫漫)