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:
PI = 3.141592653589793238460
INF =  999999999
MOD  = 1000000007
# MOD = 998244353

def add(x,y):
    return (x+y)%MOD

def sub(x,y):
    return (x-y+MOD)%MOD

def mul(x,y):
    return (x*y)%MOD

def gcd(x,y):
    if y == 0:
        return x
    return gcd(y,x%y)

def lcm(x,y):
    return (x*y)//gcd(x,y)

def power(x,y):
    res = 1
    x%=MOD
    while y!=0:
        if y&1 :
            res = mul(res,x)
        y>>=1
        x = mul(x,x)
        
    return res
        
def mod_inv(n):
    return power(n,MOD-2)

def prob(p,q):
    return mul(p,power(q,MOD-2))    
  
def ii():
    return int(input())

def li():
    return [int(i) for i in input().split()]

def ls():
    return [i for i in input().split()]

for t in range(ii()):
    t+=1

    n,s = li()
    N = str(n)

    total = 0
    for i in N:
        total+=int(i)
    if total <= s:
        print(0)
        continue
    temp =s 
    index  = 0
    while int(N[index]) < temp:
        temp-= int(N[index])
        index+=1
    
    
    l = len(N)
    if index < len(N):
        print(10**(l - index) - int(N[index:]))
        # if int(N[1]) < s- int(N[0]):
        #     print( (int(N[1]) +1)* (10**(len(N)-2)) - int(N[1:])   )
        # else:
        #     print( ( int(N[0]) +1 ) * 10**(len(N)-1) - n  )

    else:
        print(10**(len(N) ) - n )