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.math.BigInteger;
import java.util.*;

/**
 * @author Tran Anh Tai
 */
public class ProbD {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        static long LL = (long)1;
        long pow10(int y){
            if (y == 0) return LL;
            long au = pow10(y >> 1);
            au = au * au;
            if (y % 2 == 1){
                au = au * 10;
            }
            return au;
        }
        int f(long n){
            int cnt = 0;
            while (n > 0){
                cnt += (int)(n % 10);
                n = n / 10;
            }
            return cnt;
        }
        public void solve(InputReader in, PrintWriter out) {
            int t = in.nextInt();
            while (t > 0) {
                t--;
                long n = in.nextLong();
                int s = in.nextInt();
                String str = n + "";
                int cnt = str.length();
                int total = 0;
                int i = 0;
                while (i < cnt){
                    total += (str.charAt(i) - '0');
                    if (total > s){
                        break;
                    }
                    i++;
                }
                if (i == cnt){
                    out.println(0);
                    continue;
                }
                i--;
                if (i == -1){
                    out.println(pow10(cnt) - n);
                    continue;
                }
                else{
                    long cur = Long.parseLong(str.substring(0, i + 1)) + 1;
                    while (f(cur) > s){
                        i--;
                        if (i >= 0) cur = Long.parseLong(str.substring(0, i + 1)) + 1;
                        else break;
                    }
                    if (i == -1){
                        out.println(pow10(cnt) - n);
                    }
                    else{
                        out.println(cur * pow10(cnt - i - 1) - n);
                    }
                }
            }
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public double nextDouble(){
            return Double.parseDouble(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}