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:
#### -- list operations -- ####
# lst.sort()
# min_n = min(lst)
# lst.pop(index)
#### -------------------- ####

#### -- set operations -- ####
#s = set()
#s = {1,2,3,..,n}
#s.add(element)
#Cannot add a list or set inside a set
#### -------------------- ####
#### -- dict operations -- ####
#thisdict["color"] = "red"

#### -- time complexity of one loop for n interations -- ####
# {Each loop has two addition problems}
#Powers of Tens
#4 - 0.00199
#5 - 0.02293
#6 - 0.25432
#7 - 2.36288
#8 - 25.0792
#9 - 260.798
#### -------------------- ####

#### -- time complexity of one loop for n interations -- ####
# {Each loop has one incrementation problems}
#Powers of Tens
#4 - 0.00099
#5 - 0.01390
#6 - 0.14229
#7 - 1.54632
#8 - 14.5599
#9 - 146.714
#### -------------------- ####
import sys
sysinput = sys.stdin.readline

import time
start_time = time.time()

############ ---- Input Functions ---- ############
def inp():
    return(int(sysinput()))
def inlt():
	return(list(map(int,sysinput().split())))

def insr():
    s = sysinput()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,sysinput().split()))






t = inp()
while (t>0):
	t-=1
#----------------Code Start--------------------
	n,s = inlt()
	k = n
	number =[]
	order = 0
	suma =0 
	while True:
		suma += k - 10*(k//10)
		number.append(k - 10*(k//10))
		order+=1
		if k//10 == 0:
			break
		k = k//10

	number.append(0)
	# print (suma)
	
	# print (number)
	inc = 0
	for i in range(order):
		# print (number,number[i])
		if suma > s and number[i]!=0:
			# print (suma)
			inc += (10-number[i])* (10**i)
			# suma -= number[i]
			number[i] = 0
			j = i+1
			while True:
				# print (j)
				if j >= order:
					break
				if number[j]+1 == 10:
					number[j] = 0
					j+=1
				else:
					number[j] +=1
					# suma+=1
					break
		elif suma<=s:
			break
		suma = sum(number)


	print (inc)



#----------------Code Ends---------------------


# check time complexity of the code
# print("--- %s seconds ---" % (time.time() - start_time))