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 comp(lis,i,s):
    # ans=[lis[j] for j in range(i,len(lis))], this is the correct thing to do
    # print(i,s,lis)
    ans=""
    carry=0
    k=len(lis)-1
    while k>=i and lis[k]==0:
        ans="0"+ans
        k-=1
    if k<i:
        return int(2e18)
    ans=str((10-lis[k]))+ans
    lis[k]=0
    for j in range(k-1,i-1,-1):
        ans=str((9-lis[j]))+ans
        lis[j]=0
        
    ans=int(ans)

    lis[i-1],carry=(lis[i-1]+1)%10,(lis[i-1]+1)//10
    for j in range(i-2,-1,-1):
        lis[j],carry1=(lis[j]+carry)%10,(lis[j]+carry)//10
        carry=carry1
    # print(i,s,lis,ans)    
    if sum(lis)<=s:
        return ans
    else:
        return int(2e18)
for vishal in range(int(input())):
    n,s=list(map(int,input().split()))
    su,nn=0,n
    lis=[]
    
    while nn:
        su+=nn%10
        lis.append(nn%10)
        nn//=10
    lis.append(0)
    lis.append(0)
    lis.reverse()
    # # print(lis)
    # print(comp(lis,len(lis)-1))
    # exit(0)
    if su<=s:
        print("0")
        continue
    ans=int(2e18)
    for i in range(len(lis)-1,0,-1):
        # lis[i:len(lis)] make zero, and add
        # one to lis[i-1] then compute sum
        ans=min(ans,comp(lis[:],i,s))
    # make all of it as 1
    print(ans)