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:
#!/usr/local/bin/python3
t=int(input())
for _ in range(t):
    n,s=map(int,input().split())
    arr = list(map(int,str(n)))
    currSum = sum(arr)
    i = len(arr)-1
    while currSum > s:
        while arr[i] == 0:
            i -= 1
        currSum -= arr[i]
        arr[i] = 0
        i -= 1
        while i >= 0 and arr[i] == 9:
            currSum -= arr[i]
            arr[i] = 0
            i -= 1
        if i < 0:
            currSum += 1
            arr = [1]+arr
            i = 0
        else:
            currSum += 1
            arr[i] += 1
    smallest = int(''.join(map(str,arr)))
    # print(smallest)
    print(smallest-n)


"""
Given n and s.
What's the smallest number x >= n s.t. sum(digits(x)) <= s?
Return x-n.

Obsevations:
- This whole line of reasoning was assuming >= s, not <= s.
    - smallest = d..999, where d = s%9
        - If n < smallest, then ans = smallest-n
        - Else:
            - What is the second smallest that's = s?
                - (d+1)...998
            - What is the smallest that's == s+1?
                if d != 9:
                    - (d+1)...999
                else:
                    - 19...999
            - Clearly, the next numbers to check are (d+1)...998 and (d+1)...999
        
- Is this even possible?
    - This is always possible because we can always get to 10...000 from any number, and
    since we're increasing by 1, we will be able to get any sum we want.
    
if sum(digits(n)) <= s:
    we don't need to do anything
else:
    - We can set the last non-zero digit to 0 and increase the one to the left of it.
        - This decreases the sum by d-1, where d is the last elem
        - This is kinda like a carry operation.
    
k
Examples:
40 12
    - 40

38 12
    - 38

11111 2
    - 20000

9999888776644 4
    - 1111000000000

2 6
    - 2

 821934894 1
 900000000

514 7
    - 520

 821934894 11
 830000000


"""