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 f(num,rn,x):	
	sum=0
	i=0
	j=1
	c=0
	while i <=rn-1:
		# input()
		buffX=int(num[i])
		if i>0 :
			if int(num[i-1])!=0:
				c=int(num[i-1])
				j=1
			else:
				j=j+1
		else:
			j=1
		sum=sum + buffX
		# print("[num]=",int(num),"i=",i,"j=",j,"sum=",sum)		
		if sum>x :
			# print("gate1 j=",j)
			if i>0:
				# print("f: "+plus1(num,i-j))
				if c==x:
					return f(plus1(num,i-j),rn,x)
				else:
					return f(plus1(num,i-1),rn,x)		
			else:
				# print("f: "+str(10**len(num)))
				return f(str(10**len(num)),rn,x)
		if i == rn-1:
			# print("gate2")
			return num
		i=i+1

def plus1 (num,x):
	# print("beforeNum="+num+"  x="+str(x))
	while x >= 0:
		buff=int(num[x])+1
		if buff > 9:		

			buff0=str(10**len(num[x+1:]))
			num=num[:x]+"0"+buff0[1:]			
			if x==0:
				num="1"+num
			x=x-1
		else:
			buff0=str(10**len(num[x+1:]))
			num=num[:x]+str(buff)+buff0[1:]	
			break
	# print("afterNum="+num)
	return num

if __name__ == '__main__':
   	n=int(input())
   	for i in range(n):
   		ip1,ip2=input().split()
   		ip2=int(ip2)  	
   		r=len(ip1)
   		print(int(f(ip1,r,ip2))-int(ip1))