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:
from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import random
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
    #------------------Sublime--------------------------------------#
    sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
    def I():return (int(input()))
    def In():return(map(int,input().split()))
else:
    #------------------PYPY FAst I/o--------------------------------#
    def I():return (int(stdin.readline()))
    def In():return(map(int,stdin.readline().split()))
#sys.setrecursionlimit(1500)
def dict(a):
    d={} 
    for x in a:
        if d.get(x,-1)!=-1:
            d[x]+=1
        else:
            d[x]=1
    return d
def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bi.bisect_left(a, x)
    if i != len(a):
        return i
    else:            
        return -1
def solve(a,b,x,y,n):
    temp=min((b-y),n)
    b-=temp
    n-=temp
    temp=min((a-x),n)
    a-=temp
    n-=temp
    return a*b
def main():
    try:
        a,b=In()
        an=1
        l=list(str(a))
        n=len(l)
        tsum=0
        masu=1
        for x in range(n):
            tsum+=int(l[x])
        if tsum==b:
            print(0)
        elif tsum<b:
            print(0)
        else:
            pos=-1
            temp=0

            for i in range(n-1,-1,-1):
                if tsum-temp+1<=b:
                    pos=i
                    break
                temp+=int(l[i])
            if pos==-1:
                ans=[]
                q=0
                for i in range(n-1,-1,-1):
                    if q==0:
                        if int(l[i])==0:
                            ans.insert(0,str(0))
                        else:
                            ans.insert(0,str(10-int(l[i])))
                            q=1
                    else:
                        ans.insert(0,str(9-int(l[i])))
                print(int(''.join(ans)))
            else:
                #print(pos,'*')
                ans=[]
                q=0
                for i in range(n-1,pos,-1):
                    if q==0:
                        if int(l[i])==0:
                            ans.insert(0,str(0))
                        else:
                            ans.insert(0,str(10-int(l[i])))
                            q=1
                    else:
                        ans.insert(0,str(9-int(l[i])))
                print(int(''.join(ans)))
            
        
    except:
        pass
        
M = 998244353
P = 1000000007
 
if __name__ == '__main__':
    for _ in range(I()):main()
    #for _ in range(1):main()