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
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def inc(d,c):
	d[c]=d[c]+1 if c in d else 1
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<n	
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)


t=fi()
def sod(n):
	p=str(n)
	c=0
	for i in range(len(p)):
		c+=int(p[i])
	return c	
while t>0:
	t-=1
	n,s=mi()
	mm=n
	l=sod(n)
	need=s-l
	#print(l)
	if need>=0:
		print(0)
		continue
	"""n=10**(len(str(n)))
	l=sod(n)
	need=1-l	
	print(n)"""
	s=list(str(n))	
	m=len(s)
	c=1
	ans=0
	need=-need
	need+=1
	#print(need)
	flag=0
	z=-1
	for i in range(m-1,-1,-1):
		if int(s[i])>=need:
			ans+=need*c
			if i==0:
				s[i]="0"
				s.insert(0,"1")
				flag=1
			else:
				z=i	
				s[i]="0"
			break
			
		else:
			ans+=(int(s[i]))*c
			need-=(int(s[i]))
			s[i]="0"
		c*=10

	if flag==1:	
		print(int("".join(s))-mm)	
		continue
	m=int("".join(s[:z]))
	m+=1
	k=int(str(m)+"".join(s[z:]))
	print(k-mm)