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 PYTHON):

Solution:
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

for _ in xrange(int(input())):
    ns, s = input().split()
    nstr = ['0'] + list(ns)
    ls = len(ns)
    s = int(s)
    n = int(ns)
    cursum = sum((int(c) for c in nstr))
    if cursum <= s:
        ans = 0
    else:
        ii = 0
        while True:
            ii += 1
            cum = 0
            for i in range(len(nstr)):
                cum += int(nstr[i])
                if s - cum <=0:
                    nstr[i] = str(int(nstr[i])+1)
                    ii = i
                    while ii-1 >= 0 and nstr[ii] == '10': 
                        nstr[ii] = '0'
                        nstr[ii-1] = str(int(nstr[ii-1])+1)
                        ii -= 1
                    nstr = nstr[:i+1]
                    break
            else:
                nstr[-2] += 1
                nstr = nstr[:-1]
            cursum = sum((int(c) for c in nstr))
            if cursum <= s:
                ans = int(''.join(nstr) + '0' * (ls-len(nstr)+1)) - n
                break
    print(ans)