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.*;

public class Main {

    public static void main(String[] args) throws IOException {
//        br = new BufferedReader(new FileReader(new File("input.txt")));
//        out = new PrintWriter(new File("output.txt"));
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        int PUTEN = nextInt();
        for (int Puten_pomogi = 0; Puten_pomogi < PUTEN; Puten_pomogi++) {
            char[] n = next().toCharArray();
            int s = nextInt();
            int where = n.length - 1;
            int sum = 0;
            int[] ll = new int[n.length];
            for (int i = 0; i < n.length; i++) {
                ll[i] += n[i] - '0';
                if (i > 0)
                    ll[i] += ll[i - 1];
            }
            if (ll[n.length - 1] <= s) {
                out.println(0);
                continue;
            }
            while (where >= 0 && ll[where] + 1 > s) {
                where--;
            }
            Stack<Integer> ans = new Stack<>();
            int ind = n.length - 1;
            while (n[ind] == '0' && ind > 0) {
                ans.add(0);
                ind--;
            }
            ans.add(10 - n[ind] + '0');
            where++;
            while (where < n.length && n[where] == '9')
                where++;
            for (int i = ind - 1; i >= where; i--) {
                ans.add(9 - n[i] + '0');
            }
            int k = ans.size();
            for (int i = 0; i < k; i++) {
                out.print(ans.pop());
            }
            out.println();

        }
        out.close();

    }

    static BufferedReader br;
    static PrintWriter out;
    static StringTokenizer in = new StringTokenizer("");

    static String next() throws IOException {
        while (!in.hasMoreTokens()) {
            in = new StringTokenizer(br.readLine());
        }
        return in.nextToken();
    }

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

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

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