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
import sys

input = sys.stdin.readline


# Input Functions
def inp():
    return int(input())


def inlst():
    return (list(map(int, input().split())))


def instr():
    s = input()
    return list(s[:len(s) - 1])


def invar():
    return map(int, input().split())


# def pba(a, b, m):
#     if a == b:
#         return m
#     if abs(a - b) <= 10:
#         return m + 1
#     return math.ceil(abs(b-a)/10)
# n = inp()
# for i in range(n):
#     a, b = invar()
#     m = 0
#     print(pba(a, b, m))

# def pbb(a, b, x, y, n):
#     da = min(a-x, n)
#     a -= da
#     n -= da
#     db = min(b-y, n)
#     b -= db
#     return a * b
# t = inp()
# for i in range(t):
#     a, b, x, y, n = invar()
#     print(min(pbb(a, b, x, y, n),pbb(b, a, y, x, n)))

# def pbc(n, x, y):
#     lst = []
#     max = 10**18
#
#     for i in range(1, 51):
#         for j in range(1, 51):
#             temp = [i + j * d for d in range(n)]
#             if x in temp and y in temp:
#                 if temp[-1] < max:
#                     max = temp[-1]
#                     lst = temp
#
#     return lst
# for _ in range(inp()):
#     n, x, y = invar()
#     print(*pbc(n, x, y))

def sumd(n):
    if n < 10:
        return n
    return n % 10 + sumd(n // 10)

def pbd(n, s):
    sn = sumd(n)
    res = 0

    i = 1
    while sn > s:
        res += i * (10 - n % 10)
        n += (10 - n % 10)
        n //= 10
        sn = sumd(n)
        i *= 10

    return res


for _ in range(inp()):
    n, s = invar()
    print(pbd(n, s))