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:
//package codeforces._667;

import java.io.*;
import java.util.StringTokenizer;

public class _D {

    public static void main (String[] args) throws Exception {

//        String s = "5\n" +
//                "2 1\n" +
//                "1 1\n" +
//                "500 4\n" +
//                "217871987498122 10\n" +
//                "100000000000000001 1";

        String s = "1\n" +
                "22100 4\n";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int T = nin();
        next_test:
        for (int t=1; t<=T; ++t) {
            rl(); long n=nlo(); int S=nin();
            char N[] = Long.toString(n).toCharArray(); int l=N.length;
            int _S=0;
            int i=0;
            while (i<l && _S<S) {
                _S+=(N[i++]-'0');
            }

            --i;
            _S-=(N[i]-'0');
            long r=0, r10=1;
            for (; i<l; ++i) {
                _S+=(N[i]-'0');
                r*=10; r+=(N[i]-'0');
                r10*=10;
            }
            if (_S>S) {
                bw.write(Long.toString(r10-r)+"\n");
            } else {
                bw.write("0\n");
            }

        }
        bw.flush();
    }

    static BufferedReader br; static BufferedWriter bw; static StringTokenizer st;
    static void rl() throws Exception{ st = new StringTokenizer(br.readLine()); }
    static long nlo(){ return Long.parseLong(st.nextToken()); }
    static int nin(){ return Integer.parseInt(st.nextToken()); }
    /*private static void te(){}*/
    static double ndo(){ return Double.parseDouble(st.nextToken()); }
    static char[] nca(){ return st.nextToken().toCharArray(); }
}