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:
from itertools import permutations
#from fractions import Fraction
from collections import defaultdict
from math import*
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import*
import copy
import itertools
BUFSIZE = 8192



def sum(s1):
    ans=0
    for i in range(len(s1)):
        ans+=int(s1[i])
    return ans

t=int(input())
while t:
    t-=1
    n,s=map(int,input().split())
    s1=str(n)
    if sum(s1)<=s:
        print("0")
    else:
        n=len(s1)
        arr=[]
        val=0
        for i in range(n):
            val+=int(s1[i])
            arr.append(val)
#        print(arr)
        ns=""
        pos=-1
        for i in range(n-1,-1,-1):
            ns+="0"
            nss=ns
            for j in range(i-1,-1,-1):
                if s1[j]!=9:
                    summ=arr[j]
                    if summ+1<=s:
                        pos=j
                    break
            if pos!=-1:
                break
        position=0 if pos==-1 else pos
        num=""
#        print(n,position)
        if position==0:
            num="1"
            for i in range(n):
                num+="0"
            val=int(num)-int(s1)

            temp=str(int(s1[0])+1)
            for i in range(n-1):
                temp+="0"
            val2=int(temp)-int(s1)
            ans=0
            if sum(temp)<=s:
                ans=min(val,val2)
            else:
                ans=val
            print(ans)#ans+int(s1))

        else:
            for i in range(position+1):
                num+=s1[i]
            num=str(int(num)+1)
#            print(num)
            for i in range(n-position-1):
                num+="0"
#            print(num)
            ans=int(num)-int(s1)
            print(ans)#,ans+int(s1))