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.*;
import java.util.Random;
import java.util.StringTokenizer;

public class TaskD {
    static FastIO io = new FastIO("in.txt");
    static int T;
    static long N, S;
    public static void main(String[] args) throws Exception {
        T = io.nextInt();
        while (T-- > 0){
            N = io.nextLong();
            S = io.nextLong();
            String NS = "0" + N + "";
            int n = NS.length();
            int i = 0, c = 0;
            int C = 0;
            for(int j=0; j<n; j++){
                C += NS.charAt(j) - '0';
            }
            while(i < n){
                int ci = NS.charAt(i) - '0';
                if(ci < 9 && ci + 1 + c <= S) {
                    c += ci;
                    i++;
                }else if(ci == 9 && ci + c <= S){
                    c += ci;
                    i++;
                }else{
                    break;
                }
            }
            if(i >= n || C <= S){
                io.println(0);
            }else{
                char[] NS2 = NS.toCharArray();
                //NS2[i-1]++;
                for(int j=i; j<n; j++){
                    NS2[j] = '0';
                }
                long t = Long.parseLong(new String(NS2));
                t += mpow(10, n-i);
                io.println(t - N);
            }
        }
        io.flush();
    }

    static long mpow(long a, long n){
        if(n == 0) return 1;
        long r = mpow(a, n / 2);
        r *= r;
        if(n % 2 == 1) r *= a;
        return r;
    }

    static class Util {
        static <T> void shuffle(T[] ts) {
            int n = ts.length;
            Random random = new Random();
            for (int i = n - 1; i >= 0; i--) {
                int j = random.nextInt(i + 1);
                if (j != i) {
                    T tmp = ts[i];
                    ts[i] = ts[j];
                    ts[j] = tmp;
                }
            }
        }

        static void shuffle(int[] ts) {
            int n = ts.length;
            Random random = new Random();
            for (int i = n - 1; i >= 0; i--) {
                int j = random.nextInt(i + 1);
                if (j != i) {
                    int tmp = ts[i];
                    ts[i] = ts[j];
                    ts[j] = tmp;
                }
            }
        }

        static void shuffle(long[] ts) {
            int n = ts.length;
            Random random = new Random();
            for (int i = n - 1; i >= 0; i--) {
                int j = random.nextInt(i + 1);
                if (j != i) {
                    long tmp = ts[i];
                    ts[i] = ts[j];
                    ts[j] = tmp;
                }
            }
        }

        static void shuffle(double[] ts) {
            int n = ts.length;
            Random random = new Random();
            for (int i = n - 1; i >= 0; i--) {
                int j = random.nextInt(i + 1);
                if (j != i) {
                    double tmp = ts[i];
                    ts[i] = ts[j];
                    ts[j] = tmp;
                }
            }
        }

        static void shuffle(char[] ts) {
            int n = ts.length;
            Random random = new Random();
            for (int i = n - 1; i >= 0; i--) {
                int j = random.nextInt(i + 1);
                if (j != i) {
                    char tmp = ts[i];
                    ts[i] = ts[j];
                    ts[j] = tmp;
                }
            }
        }
    }
    static class FastIO {
        static StringBuilder sb = new StringBuilder();
        static BufferedReader br;
        static StringTokenizer st;
        static PrintStream ps = new PrintStream(System.out);

        public FastIO(String fname) {
            try {
                File input = new File(fname);
                if (input.exists()) {
                    System.setIn(new FileInputStream(fname));
                }
            }catch (Exception e){
                e.printStackTrace();
            }

            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        void flush(){
            System.out.print(sb.toString());
            sb.setLength(0);
        }

        void print(Object o){
            sb.append(o);
        }

        void println(Object o){
            sb.append(o);
            sb.append('\n');
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}