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 math import *
from bisect import *
from collections import *
from decimal import *
def inp():
    return int(input())
def st():
    return input().rstrip('\n')
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
t=inp()
while(t):
    t-=1
    n,s=ma()
    x=str(n)
    s1=0
    for i in x:
        s1+=int(i)
    if(s>=s1):
        print(0)
        continue
    pre=0
    po=0
    for i in x:
        po+=1
        pre+=int(i)
        if(pre<s):
            continue
        if(pre==int(x[0])):
            ref='1'+('0'*(len(x)))
            ref=int(ref)
            print(ref-n)
            break
        else:
            pre=x[:po-2]
            if(x[po-2]!='9'):
                pre+=str(int(x[po-2])+1)
            else:
                pre1=0
                po-=2
                while(po>=0):
                    if(x[po]=='9'):
                        pre1+=1
                        po-=1
                        continue
                    break
                if(po==-1):
                    ref='1'+('0'*(len(x)))
                    ref=int(ref)
                    print(ref-n)
                    break
                else:
                    pre=x[:po]+str(int(x[po])+1)
                    pre+='0'*pre1
            for j in range(len(x)-len(pre)):
                pre+='0'
            pre=int(pre)
            print(pre-n)
            break