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.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    static PrintWriter out;
    static Reader in;
    public static void main(String[] args) throws IOException {
        //out = new PrintWriter(new File("out.txt"));
        //PrintWriter out = new PrintWriter(System.out);
        //in = new Reader(new FileInputStream("in.txt"));
        //Reader in = new Reader();
        input_output();
        Main solver = new Main();
        solver.solve();
        out.flush();
        out.close();
 
    }
 
    static int INF = (int)1e9;
    static int maxn = 1000;
    static int mod=(int)1e9+7 ;
    static int n, m, q, k, t;

    void solve() throws IOException{
        t = in.nextInt();

        while (t --> 0) {
            String s = in.next();
            n = in.nextInt();

            long[][] pre = new long[19][10];
            pre[0][1] = 1;
            for (int i = 2; i <= 9; i++) pre[0][i] = pre[0][1]*i;
            pre[1][1] = 10;
            for (int i = 2; i < 10; i++) pre[1][i] = pre[1][1]*i;
            for (int i = 2; i <= 18; i++) {
                for (int j = 1; j <= 9; j++) {
                    if (j == 1) pre[i][j] = pre[i-1][1]*10;
                    pre[i][j] = pre[i][1]*j;
                }
            }

            int sum = 0;
            for (int i = 0; i < s.length(); i++) sum += s.charAt(i)-'0';

            if (sum <= n) {
                out.println(0);
                continue;
            }

            long ans = 0;
            int[] arr = new int[maxn];
            for (int i = maxn-1; i >= maxn-s.length(); i--) {
                arr[i] = s.charAt(s.length()-1-(maxn-1-i))-'0';
            }
            //System.out.println(sum+" "+n);
            while (sum > n) {

                int idx = -1;
                for (int i = maxn-1; i >= 0; i--) {
                    if (arr[i] != 0) {
                        idx = i;
                        break;
                    }
                }
                //System.out.println(idx+" "+arr[idx]+" "+pre[maxn-1-idx][1]+" "+(maxn-1-idx));
                ans += (long)(10-arr[idx])*pre[maxn-1-idx][1];
                sum -= arr[idx];
                arr[idx] = 0;
                idx--;
                while (arr[idx] == 9) {
                    arr[idx] = 0;
                    sum-=9;
                    idx--;
                }
                arr[idx]++;
                sum++;
            }

            out.println(ans);
        }
    }

    //<>

    static class Reader {
 
        private InputStream mIs;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
    
        public Reader() {
            this(System.in);
        }
    
        public Reader(InputStream is) {
            mIs = is;
        }
    
        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
    
        }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = mIs.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }
    
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
    
        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
    
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
    
        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
    
        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
    
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    
        public boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
 
    }
    static void input_output() throws IOException {
        File f = new File("in.txt");
        if(f.exists() && !f.isDirectory()) { 
            in = new Reader(new FileInputStream("in.txt"));
        } else in = new Reader();
        f = new File("out.txt");
        if(f.exists() && !f.isDirectory()) {
            out = new PrintWriter(new File("out.txt"));
        } else out = new PrintWriter(System.out);
    }
}