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 math
# t = int(input())
# while t > 0:
#     a,b,x,y,n = map(int, input().split(' '))
#     if a-n == 1:
#         print(b)
#         t -= 1
#         continue
#     elif b-n == 1:
#         print(a)
#         t -= 1
#         continue
#     if a < b:
#         if a-n >= x:
#             a -= n
#             print(a*b)
#         else:
#             k = a
#             a = x
#             n -= k-x
#             if b-n >= y:
#                 b -= n
#                 print(a*b)
#             else:
#                 b = y
#                 print(a*b)
#     elif b < a:
#         if b-n >= y:
#             b -= n
#             print(a*b)
#         else:
#             k = b
#             b = y
#             n -= k-y
#             if a-n >= x:
#                 a -= n
#                 print(a*b)
#             else:
#                 a = x
#                 print(a*b)
#     else:
#         if x <= y:
#             if a-n >= x:
#                 a -= n
#                 print(a*b)
#             else:
#                 k = a
#                 a = x
#                 n -= k-x
#                 if b-n >= y:
#                     b -= n
#                     print(a*b)
#                 else:
#                     b = y
#                     print(a*b)
#         else:
#             if b-n >= y:
#                 b -= n
#                 print(a*b)
#             else:
#                 k = b
#                 b = y
#                 n -= k-y
#                 if a-n >= x:
#                     a -= n
#                     print(a*b)
#                 else:
#                     a = x
#                     print(a*b)
#     t -= 1

def digit(n):
    res = 0
    for i in str(n):
        res += int(i)
    return res

t = int(input())
while t > 0:
    n,s = map(int, input().split(' '))
    var = 0
    if digit(n) <= s:
        print(0)
        t -= 1
        continue
    n = str(n)
    x = 1
    for i in n:
        if var+int(i) >= s:
            break
        var += int(i)
        x += 1
    if x == 0:
        d = '0'*len(n)
        f = '1'+d
        print(int(n)-int(f))
        t -= 1
        continue
    y = len(n[x-1:])
    k = n[:x-1]
    if k == '':
        ans = '1'+('0'*y)
    else:
        ans = str((int(k)+1))+('0'*y)
    print(int(ans)-int(n))
    t -= 1