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:
import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

def num(n):
	ans=[]
	while n:
		ans.append(n%10)
		n//=10
	ans.append(0)
	return ans

def sod(n):
	if n<10:
		return n
	return (n%10)+sod(n//10)

t=inp()
for _ in range(t):
	n,k=invr()
	number=num(n)
	digit=len(number)-1
	
	answer=10**(digit+1)
	if sod(n)<=k:
		answer=n
	
	for i in range(digit):
		temp=list(number)
		for j in range(i+1):
			temp[j]=0
		for j in range(i+1,digit+1):
			if temp[j]==9:
				temp[j]=0
			else:
				temp[j]+=1
				break
		temp.reverse()		
		curr=0
		for j in range(digit+1):
			curr*=10
			curr+=temp[j]

		if sod(curr)<=k and curr<=answer:
			answer=curr
		
		#print(curr,sod(curr))
	print(answer-n)