Problem: You are given a positive integer n. In one move, you can increase n by one (i.e. make n := n + 1). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 2 ⋅ 10^4) — the number of test cases. Then t test cases follow.

The only line of the test case contains two integers n and s (1 ≤ n ≤ 10^{18}; 1 ≤ s ≤ 162).

Output

For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.

Example

Input


5
2 1
1 1
500 4
217871987498122 10
100000000000000001 1


Output


8
0
500
2128012501878
899999999999999999

Solution (in PYTHON3):

Solution:
def correct (arr,t):
	while(arr[t]>9 and t>=0):
		arr[t-1]+=1
		arr[t]=0
		t-=1
	return t

def calc(arr,t,ts,s):
	for i in range(t,len(arr)):
		arr[i]=0
	arr[t-1]+=1
	arr[t]=0
	t-=1
	t=correct(arr,t)
	ts=sum(arr)
	while(ts>s):
		arr[t-1]+=1
		arr[t]=0
		t-=1
		t=correct(arr,t)
		ts=sum(arr)

for _ in range(int(input())):
	n,s=input().split()
	n1=int(n)
	s=int(s)
	l=0
	ts=0
	arr=[0]*18+[int(n[i]) for i in range(len(n))]
	while(l!=18+len(n)):
		ts+=arr[l]
		if(ts>s):
			calc(arr,l,ts,s)
			break
		l+=1
	start=0
	for i in range(len(arr)):
		if(arr[i]>0):
			start=i
			break
	t=0
	ans=0
	# print(*arr)
	for j in range(len(arr)-1,start-1,-1):
		ans+=arr[j]*pow(10,t)
		t+=1
	
	print(ans-n1)