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
from math import sqrt
from collections import defaultdict
inpt = sys.stdin.readline

def inp():
    return(int(inpt()))

def inlist():
    return(list(map(int,inpt().split())))

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

def invr():
    return(map(int,inpt().split()))

class Graph:

    def __init__(self,n):
        self.n = n
        self.graph = defaultdict(list)
        self.marked = defaultdict(int)
    
    def addEdge(self,u,v):
        self.graph[u].append(v)
        self.graph[v].append(u)

    def dfs(self,u):

        self.marked[u] = 1

        for i in self.graph[u]:
            if(self.marked[i] == 0):
                self.dfs(i)


def main():
    
    t = inp()

    for l in range(t):
        
        n,s = invr()

        sdigit = 0
        for dgt in str(n):
            sdigit += int(dgt)

        ans = 0

        x = 1
        while(sdigit>s):
            ldgt = n%10
            if(ldgt!=0):
                ans += (10-ldgt)*x
            else:
                ans+=10*x
            n = n//10
            x = x*10
            n += 1
            sdigit = 0
            for dgt in str(n):
                sdigit += int(dgt)

        print(ans)

main()