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:
_1 = '236a'
# count = 0
# l = [list(map(int, input().split())) for i in range(5)]
# for i in range(5):
#     for j in range(5):
#         if l[i][j] == 1:
#
#             if i > 2:
#                 count += i - 2
#             elif i < 2:
#                 count += 2 - i
#             if j > 2:
#                 count += j - 2
#             elif j < 2:
#                 count += 2 - j
# print(count)
_2 = '339a'
# n = list(map(str, input().split('+')))
# n.sort()
# print('+'.join(n))
_3 = '266a'
# count = 0
# t = 0
# n1 = int(input())
# n = list(str(input()))
# for i in range(1,n1,1):
#     if n[i] == n[i-1]:
#         count +=1
# print(count)
_4 = '96a'
# flag = False
# flag1 = False
# p0=0
# p1=0
# l = list(str(input()))
# for i in l:
#     if i == '0':
#         p0 += 1
#         if p0 >= 7:
#             flag = True
#     else:
#         p0 = 0
# for i in l:
#     if i == '1':
#         p1 += 1
#         if p1 >= 7:
#             flag1 = True
#     else:
#         p1 = 0
# if flag == True or flag1 == True:
#     print("YES")
# else:
#     print("NO")
_5 = '236a'
# l = list(str(input()))
# if len(set(l)) % 2 == 0:
#     print("CHAT WITH HER!")
# else:
#     print("IGNORE HIM!")
_6 = '281a'
# l = list(str(input()))
# t = l[0].upper()
# print(t + ''.join(l[1:]))
_7 = '546a'
# s = 0
# a,b = map(int, input().split())
# while a <= b:
#     a*=3
#     b*=2
#     s+=1
# print(s)
_8 = '116a'
# t = 0
# l1 = []
# n = int(input())
# l = [list(map(int, input().split())) for i in range(n)]
# for i in range(n):
#     t += l[i][1]
#     t -= l[i][0]
#     l1.append(t)
# print(max(l1))
_9 = '977a'
# n,k = map(int, input().split())
# for i in range(k):
#     if n % 10 == 0:
#         n/=10
#     else:
#         n-=1
# print(int(n))
_10 = '266b'
# n = str(input())
# l = list(n)
# low = 0
# up = 0
# for i in l:
#     if i.islower():
#         low += 1
#     else:
#         up += 1
# if low >up:
#     print(n.lower())
# elif low < up:
#     print(n.upper())
# else:
#     print(n.lower())
_11 = '110a'
# n = list(str(input()))
# l=[]
# for i in range(len(n)):
#     if n[i] == '4' or n[i] == '7':
#         l.append(i)
# if len(l) == 4 or len(l) == 7:
#     print('YES')
# else:
#     print('NO')
_12 = '41a'
# n = str(input())
# n1 = str(input())
# if n1 == n[::-1]:
#     print('YES')
# else:
#     print("NO")
_13 = '734a'
# k = int(input())
# n = list(str(input()))
# a =0
# d =0
# for i in n:
#     if i == 'A':
#         a += 1
#     else:
#         d += 1
# if a >d:
#     print('Anton')
# elif d > a:
#     print('Danik')
# elif a == d:
#     print('Friendship')
_14 = '133a'
# n = list(str(input()))
# flag = False
# for i in n:
#     if i == 'H' or i == 'Q' or i == '9':
#         flag = True
# if flag:
#     print('YES')
# else:
#     print('NO')
_15 = '467a'
# count = 0
# n = int(input())
# l = [list(map(int, input().split())) for i in range(n)]
# for i in range(len(l)):
#     if l[i][1] - l[i][0] >= 2:
#         count += 1
# print(count)
_16 = '158a'
# count = 0
# flag = False
# n,k = map(int,input().split())
# l = list(map(int, input().split()))
# ball = l[k-1]
# for i in l:
#     if ball > 0:
#         if i >= ball:
#             count += 1
#     else:
#         flag = True
# if flag:
#     for i in l:
#         if i > 0:
#             count += 1
#     print(count)
# else:
#     print(count)
_17 = '677a'
# count = 0
# n,h = map(int, input().split())
# l = list(map(int, input().split()))
# for i in l:
#     if i > h:
#         count += 2
#     else:
#         count += 1
# print(count)
_18 = '580a'
# n = int(input())
# l = list(map(int, input().split()))
# r = []
# count = 0
# for i in range(0,n):
#     if l[i-1] <= l[i]:
#         count += 1
#         r.append(count)
#     if l[i-1] > l[i]:
#         count = 0
#         count +=1
# print(max(r))
_19 = '344a'
# n = int(input())
# l = [list(map(int, input().split())) for i in range(n)]
# c = 1
# t = l[0]
# for i in range(1,n):
#     if l[i] != t:
#         c+=1
#         t = l[i]
# print(c)
_20 = '1030a'
# flag = False
# n = int(input())
# l = list(map(int, input().split()))
# for i in l:
#     if i == 1:
#         flag = True
# if flag:
#     print('HARD')
# else:
#     print('EASY')
_21 = '705a'
# n = int(input())
# n1 = 0
# if n%2==0:
#     n1 = n/2-1
#     n1 = int(n1)
# else:
#     n1 = ((n+1)/2)-1
#     n1 = int(n1)
# h = 'I hate '
# t = 'that '
# l = 'I love '
# if n == 1:
#     print('I hate it')
# elif n == 2:
#     print('I hate that I love it')
# elif n == 3:
#     print('I hate that I love that I hate it')
# elif n > 3:
#     if n % 2 == 0:
#         print(((h+t)+(l+t))*n1+((h+t)+(l+'it')))
#     else:
#         print(((h+t)+(l+t))*n1+(h+'it'))
_22 = '318a'
# n,k = map(int, input().split())
# l = []
# for i in range(1,n+1):
#     if i%2!=0:
#         l.append(i)
# for i in range(1,n+1):
#     if i%2==0:
#         l.append(i)
# print(l[k-1])
_23 = '479a'
# n1 = int(input())
# n2 = int(input())
# n3 = int(input())
# ans = n1+n2+n3
# ans = max(ans,(n1+n2)*n3)
# ans = max(ans, n1*(n2+n3))
# ans = max(ans, n1*n2*n3)
# print(ans)
_24 = '486a'
# n = int(input())
# if n%2 ==0:
#     print(int(n/2))
# else:
#     print((round((n+1)/2))*(-1))
_25 = '61a'
# o = []
# n = list(str(input()))
# n1 = list(str(input()))
# for i in range(len(n)):
#     if n[i] == n1[i]:
#         o.append('0')
#     else:
#         o.append('1')
# print(''.join(o))
_26 = '405a'
# n = int(input())
# l = list(map(int, input().split()))
# l1 = []
# l.sort()
# for i in l:
#     l1.append(str(i))
# print(' '.join(l1))
_27 = '200b'
# def fixed_number(num):
#     return f"{num:.{12}f}"
# n = int(input())
# l = list(map(int, input().split()))
# s = sum(l)
# print(fixed_number(s/n))
_28 = '337a'
# l = list(map(str, input().split('WUB')))
# for i in l:
#     if i == '':
#         l.remove(i)
# print(' '.join(l))
_29 = '148a'
# n = int(input())
# x = list(map(int,input().split()))[1:]
# y = list(map(int,input().split()))[1:]
# lst = [0]*n
# concat = x + y
# for i in concat:
#     lst[i-1] = 1
# if 0 not in lst:
#     print("I become the guy.")
# else:
#     print("Oh, my keyboard!")
_30 = '228a'
# x = list(map(int,input().split()))
# c= set(x)
# if 4 - len(c) == 0:
#     print(0)
# else:
#     print(4 - len(c))
_31 = '25a'
# n = int(input())
#
# nums = list(map(int,input().split()))
#
# even_index = 0
# odd_index = 0
#
# parity = 0
#
# for i in range(n):
#     if nums[i] %2 == 0:
#         if even_index != 0:
#             parity = 1
#         even_index = i+1
#     else:
#         odd_index = i+1
#
# if parity == 0:
#     print(even_index)
# else:
#     print(odd_index)
_32 = '25a'
# l = list(str(input()))
# for i in l:
#     if i == '{' or i == '}' or i == ',' or i == ' ':
#         l.remove(i)
# for i in l:
#     if i == '{' or i == '}' or i == ',' or i == ' ':
#         l.remove(i)
# print(len(set(l)))
_33 = '1328a'
n = int(input())
o = []
for i in range(n):
    a,b = map(int, input().split())
    if a%b==0:
        o.append(0)
    else:
        o.append(b-(a%b))
for i in o:
    print(i)