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 input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10**19
MOD = 10**9 + 7

def digit_sum(n):

    ans = 0
    while n > 0:
        ans += n % 10
        n //= 10
    return ans

for _ in range(INT()):
    N, s = MAP()

    dsm = digit_sum(N)
    if dsm <= s:
        print(0)
        continue
    A = list(map(int, str(N)))[::-1]
    M = len(A)
    for i in range(M-1):
        if A[i] == 0:
            continue
        dsm += 1 - A[i]
        A[i] = 0
        A[i+1] += 1
        if dsm <= s:
            break
    for i in range(M-1):
        if A[i] == 10:
            dsm += 1 - A[i]
            A[i] = 0
            A[i+1] += 1
    if A[-1] == 10:
        dsm += 1 - A[-1]
        A[-1] = 0
        A.append(1)
    while dsm > s:
        dsm += 1 - A[-1]
        A[-1] = 0
        A.append(1)
    L = int(''.join(map(str, A[::-1])))
    ans = L - N
    print(ans)