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 JAVA):

Solution:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CodeForces extends Functions {

    public static void main(String[] args) {
        Scanner sc = new Scanner();
        int testCase = sc.nextInt();
        boolean cantBreak = false;
        while (testCase-- > 0) {
            String str = sc.next();
            str="00"+str;
            String[] arr = str.split("");
            int s = sc.nextInt();
            int sum = calcSum(arr);
            long res = 0L;
            if(sum<=s) {}
            else{
                for(int i=arr.length-1;i>=0;i--){
                    sum = calcSum(arr);
                    if((sum<=s || i==0) & !cantBreak)break;

                    arr[i]="0";
                    if(arr[i-1].equals("9")){
                        cantBreak = true;
                        continue;
                    }
                    arr[i-1] = String.valueOf(Integer.parseInt(arr[i-1])+1);
                    cantBreak = false;
                }

                StringBuilder sb = new StringBuilder();
                for(String ele : arr)sb.append(ele);
                res=Long.parseLong(sb.toString());

                res-=Long.parseLong(str);
            }
            System.out.println(res);


        }

    }

    private static int calcSum(String [] arr) {
        int x= 0;
        for(String ele : arr)x+=Integer.parseInt(ele);
        return x;
    }


}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    public String next(){
        while (!st.hasMoreTokens())
            try {
                st = new StringTokenizer(br.readLine());
            }catch (IOException e){
                e.printStackTrace();
            }
        return st.nextToken();

    }
    public int nextInt(){
        return Integer.parseInt(next());
    }
    public long nextLong(){
        return Long.parseLong(next());
    }
    public double nextDouble(){
        return Double.parseDouble(next());
    }
    public int[] setIntegerArray(int n){
        int[] arr =new int[n];
        for(int i=0;i<n;i++)arr[i] = nextInt();
        return arr;
    }
    public long[] setLongArray(int n){
        long[] arr =new long[n];
        for(int i=0;i<n;i++)arr[i] = nextLong();
        return arr;
    }
}
 class Functions {
    public static int mod = (int)1e9+7;
    public static void sort(int[] a){
        ArrayList<Integer> temp = new ArrayList<>();
        for (int j : a) temp.add(j);
        Collections.sort(temp);;
        for(int i=0;i<a.length;i++)a[i] = temp.get(i);
    }
    public static long factorial(int n){
        long fact = 1L;
        for(int i=2;i<=n;i++)fact=  (fact*i)%mod;
        return fact;
    }
    public static void sortRev(int[] a){
        sort(a);
        int left = 0;
        int right = a.length-1;
        while (left<right){
            int temp =a[left];
            a[left] = a[right];
            a[right] = temp;
            left++;
            right--;
        }
    }
}