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{
    static long[] arr;

    static long pow(int exp){
        long ret = 1;
        for(int i=0;i<exp;i++){
            ret *= 10;
        }
        return ret;
    }

    static long proc(int index, int digit){
        long ret = 0;
        for(int i=index;i<digit;i++){
            ret += arr[i]*pow(digit-i-1);
        }
        return ret;
    }

    public static void main(String[] args) throws Exception{
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        FastScanner fs = new FastScanner(System.in);

        int T = fs.readInt();

        for(int testCase=1;testCase<=T;testCase++){
            long n = fs.readLong();
            int s = fs.readInt();

            // count digits of n
            long tempn = n;
            int digit = 0;
            while(tempn>0){
                tempn /= 10;
                digit++;
            }

            arr = new long[digit];
            tempn = n;

            for(int i=digit-1;i>=0;i--){
                arr[i] = tempn%10;
                tempn /= 10;
            }

            int sum = 0;
            int index = 0;
            boolean flag1 = false;
            boolean flag2 = false;
            for(int i=0;i<digit;i++){
                sum += arr[i];
                if(sum == s){
                    index = i;
                    flag1 = true;
                    break;
                }else if(sum>s){
                    index = i;
                    flag2 = true;
                    break;
                }
            }

            long ans = 0;
            if(flag1){
                flag1 = false;
                for(int i=index+1;i<digit;i++){
                    if(arr[i] != 0){
                        flag1 = true;
                        break; 
                    }
                }
                if(flag1){
                    if(index == 0){
                        ans = pow(digit) - proc(index,digit);
                    }else{
                        ans = (arr[index-1]+1)*pow(digit-index)-proc(index-1, digit);
                    }
                }else{
                    ans = 0;
                }
            }else if(flag2){
                if(index == 0){
                    ans = pow(digit) - proc(index, digit);
                }else{
                    ans = (arr[index-1]+1)*pow(digit-index)-proc(index-1, digit);
                }
            }else{
                ans = 0;
            }

            pw.print(ans + "\n");
        }
        pw.close();
        fs.close();
    }
}

class FastScanner{
    
    StringTokenizer st;
    BufferedReader br;
    
    FastScanner(InputStream is) throws IOException{
        br = new BufferedReader(new InputStreamReader(is));
        st = new StringTokenizer(br.readLine());
    }
    
    FastScanner(String s) throws IOException{
        br = new BufferedReader(new FileReader(s));
        st = new StringTokenizer(br.readLine());
    }
 
    int readInt(){
        if(!st.hasMoreTokens()){
            try{
                st = new StringTokenizer(br.readLine());
            }catch(IOException ie){
                ie.printStackTrace();
            }
        }
        return Integer.parseInt(st.nextToken());
    }
 
    long readLong(){
        if(!st.hasMoreTokens()){
            try{
                st = new StringTokenizer(br.readLine());
            }catch(IOException ie){
                ie.printStackTrace();
            }
        }
        return Long.parseLong(st.nextToken());
    }
 
    void close() throws IOException{
        br.close();
    }
}