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


#def solve(a,b,c,d):
def solve(n,s):
    digits = [int(x) for x in str(n)]
    if sum(digits) <= s:
        return 0
    # need to go up to next digit
    if digits[0] > s:
        targ = int('1'+'0'*len(digits))
        return targ-n

    #print(n,s)
    #print(digits)
    # should test 9300 10 ===> should be 700
    
    # else see how many digits on the  left can leave unchanged
    lft = [0]
    nd = 0
    while sum(lft) < s:
        lft.append(digits[nd])
        nd += 1
    #print(lft,nd)
    if True: #sum(lft)==s:
        # can just increase the rightmost (non-9) by 1
        ith = nd-1
        while lft[ith] == 9:
            ith -= 1
        #print('ith:',ith)
        lft[ith]+=1
        lft = lft[:ith+1]
        #print('lft:',lft)
        lft.extend( [0]*(len(digits)-ith) )
        targ = int(''.join([str(x) for x in lft]))
    #else:
        #targ = 0

    return targ-n


if __name__ == '__main__':
    IN = [x.strip() for x in sys.stdin.readlines()]

    T = int(IN[0])
    cur = 0
    for ti in range(T):
        #a = int(IN[cur])
        #a = [int(x) for x in IN[cur].split(' ')]
        n,s = [int(x) for x in IN[cur+1].split(' ')]
        res = solve(n,s)
        print(res)
        cur += 1