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.lang.*;
import java.io.*;

// Created by @thesupremeone on 14/03/21
public class DecreaseTheSumOfDigits {
    BufferedReader in;
    BufferedWriter out;
    StringTokenizer st;
    boolean onlineJudge;

    int sum(long n){
        long t = n;
        int sum = 0;
        while (t>0){
            sum += t%10;
            t /= 10;
        }
        return sum;
    }

    int digit(long n){
        long t = n;
        int count = 0;
        while (t>0){
            count++;
            t /= 10;
        }
        return count;
    }

    // My Solution
    void solve() throws IOException {
        int t = getInt();
        while (t-->0){
            long n = getLong();
            int s = getInt();
            int carry = 0;
            int[] com = new int[digit(n)+1];
            int i = com.length-1;
            while (sum(n)>s){
                long d = n%10;
                if(d!=0){
                    com[i] = (int) (10-d);
                    n += 10-d;
                }
                n /= 10;
                i--;
            }
            StringBuilder ansBuilder = new StringBuilder();
            for (int j = 0; j<com.length; j++) {
                ansBuilder.append(com[j]);
            }
            println(""+Long.parseLong(ansBuilder.toString()));
        }
    }
    // Handling CodeExecution
    public static void main(String[] args) throws Exception {
        new DecreaseTheSumOfDigits().run();
    }
    void run() throws IOException {
        onlineJudge = isOnlineJudge();
        // Defining Input Streams
        if (onlineJudge) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new BufferedWriter(new OutputStreamWriter(System.out));
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new BufferedWriter(new FileWriter("output.txt"));
        }
        // Running Logic
        solve();
        out.flush();
        // Run example test cases
        if (!onlineJudge) {
            BufferedReader output = new BufferedReader(new FileReader("output.txt"));
            BufferedReader answer = new BufferedReader(new FileReader("answer.txt"));
            StringBuilder outFile = new StringBuilder();
            StringBuilder ansFile = new StringBuilder();
            String temp;
            while ((temp = output.readLine()) != null)
                outFile.append(temp.trim());
            while ((temp = answer.readLine()) != null)
                ansFile.append(temp.trim());
            if (outFile.toString().equals(ansFile.toString()))
                System.out.println("Test Cases Passed!!!");
            else
                System.out.println("Failed...");
        }
    }
    // Checks whether the code is running on OnlineJudge or LocalSystem
    boolean isOnlineJudge() {
        try {
            return System.getProperty("ONLINE_JUDGE")!=null
                    || System.getProperty("LOCAL")==null;
        } catch (Exception e) {
            return true;
        }
    }
    // Some functions
    void print(String... s) throws IOException {
        for (String value : s) out.write(value);
    }
    void println(String... s) throws IOException{
        print(s);
        out.newLine();
    }
    String getLine() throws IOException{
        return in.readLine();
    }
    String getToken() throws IOException{
        if(st==null || !st.hasMoreTokens())
            st = new StringTokenizer(getLine());
        return st.nextToken();
    }
    int getInt() throws IOException {
        return Integer.parseInt(getToken());
    }
    long getLong() throws IOException {
        return Long.parseLong(getToken());
    }
    int[] getInts(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = getInt();
        return a;
    }
    long[] getLongs(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = getLong();
        return a;
    }
    int[][] getIntMat(int n, int m) throws IOException {
        int[][] mat = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                mat[i][j] = getInt();
        return mat;
    }
    char[][] getCharMat(int n, int m) throws IOException {
        char[][] mat = new char[n][m];
        for (int i = 0; i < n; i++) {
            String s = getLine();
            for (int j = 0; j < m; j++)
                mat[i][j] = s.charAt(j);
        }
        return mat;
    }
}