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 bisect
import collections
import functools
import itertools
import math
import heapq
import random
import string


def repeat(_func=None, *, times=1):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            for _ in range(times):
                func(*args, **kwargs)

        return wrapper

    if _func is None:
        return decorator
    else:
        return decorator(_func)


def unpack(func=int):
    return map(func, input().split())


def l_unpack(func=int):
    """list unpack"""
    return list(map(func, input().split()))


def s_unpack(func=int, rev=False):
    """sorted list unpack"""
    return sorted(map(func, input().split()), reverse=rev)


def ml_unpack(n):  # multiple line unpack
    """list of n integers passed on n line, one on each"""
    return [int(input()) for _ in range(n)]


def range_n():
    return range(int(input()))


def getint():
    return int(input())


def factor(n):
    d = {}
    while not n % 2:
        d[2] = d.get(2, 0) + 1
        n //= 2
    i = 3
    while i * i <= n:
        while not n % i:
            d[i] = d.get(i, 0) + 1
            n //= i
        i += 2
    if n > 1:
        d[n] = d.get(n, 0) + 1
    return d


def get_sum(a):
    """return sum of difference of all unique pairs"""
    ans = 0
    n = len(a)
    for i in range(n):
        # ans += (a[i] * i) - (n - i - 1) * a[i]
        ans += (i - (n - i - 1)) * a[i]
    return ans


def digitsum(n):
    ans = 0
    while n:
        ans += n % 10
        n //= 10
    return ans


@repeat(times=getint())
def main():
    n, s = unpack()
    m = n
    k = digitsum(n)
    if k <= s:
        print(0)
    else:
        cnt = 0
        while k >= s:
            n //= 10
            cnt += 1
            k = digitsum(n)
        n += 1
        k = digitsum(n)
        while k > s:
            n //= 10
            cnt += 1
            k = digitsum(n)
        n = int(str(n) + '0' * cnt)

        print(n - m)


main()