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

public class Solution {
    public static int cycles = 0;

    public static int[] nextArray(FastReader sc1, int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc1.nextInt();
        }
        return arr;
    }

    public static void printMatrix(int[][] mat){
        for(int i=0; i<mat.length; i++){
            for(int j=0; j<mat[0].length; j++){
                System.out.print(mat[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println();
    }

    public static void dfs(int node, int[][] adj, int n, int pass, int[] vis){
        vis[node] = pass;
        for(int i=0; i<n; i++){
            if(adj[node][i] == 1 && vis[i]==0){
                dfs(i, adj, n, pass, vis);
            }
        }
    }

    public static void main(String[] args) {
        FastReader sc1 = new FastReader();
        StringBuilder sb = new StringBuilder();

        int tc = sc1.nextInt();
        int ch = 0;

        while(ch<tc){
            long n = sc1.nextLong();
            int s = sc1.nextInt();

            int[] arr = new int[20];
            int st = 0;
            int sum = 0;
            while(n != 0){
                int dig = (int)(n%10L);
                arr[st] = dig;
                n = n/10;
                st++;
                sum += dig;
            }

            if(sum <= s){
                sb.append("0 \n");
            }
            else{
                long moves = 0L;
                for(int i=0; i<20; i++){
                    if(arr[i] > 0){
                        int diff = 10 - arr[i];
                        int red = arr[i];
                        sum -= red;
                        moves += (long)diff * (long)Math.pow(10.0, i);

                        int cind = i+1;
                        while(true){
                            arr[cind]++;
                            if(arr[cind] == 10){
                                arr[cind] = 0;
                                sum -= 9;
                            }
                            else{
                                sum++;
                                break;
                            }
                            cind++;
                        }
                    }
                    if(sum <= s){
                        break;
                    }
                }
                sb.append(moves+"\n");
            }
            ch++;
        }
        System.out.print(sb.toString());
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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());
        }

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