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.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class D {

    public static void main(String[] args) throws IOException {
        new D().run();
    }

    private void load_inputs(final BufferedReader br) throws IOException {
        try (PrintWriter pw = select_output();) {
            int t = Integer.valueOf(br.readLine().trim());
            while(t-- > 0) {
                long[] ns = Arrays.stream(br.readLine().trim().split("\\s+")).mapToLong(v -> Long.valueOf(v)).toArray();
                solve(ns[0], (int)ns[1], pw);
            }
        }
    }
    
    private void solve(final long n, final int s, final PrintWriter pw) {
//        System.out.println("---");
        StringBuilder ns = new StringBuilder(Long.toString(n));
        int sum = 0;
        int i = 0;
        for(; i < ns.length(); i++) {
            sum += ns.charAt(i) - '0';
            if(sum > s) {
                break;
            }
        }
        long res = 0;
        if(i < ns.length()) {
            for(int j = i + 1; j < ns.length(); j++) {
                ns.setCharAt(j, '0');
            }
//            System.out.println(ns);
            sum -= ns.charAt(i) - '0';
            ns.setCharAt(i, '0');
            i--;
            while(true) {
                if(i < 0) {
                    sum = 1;
                    ns.insert(0, '1');
                    break;
                } else {
                    int dig = ns.charAt(i) - '0';
                    if(dig < 9 && sum + 1 <= s) {
                        ns.setCharAt(i, (char)('0' + dig + 1));
                        break;
                    } else {
                        ns.setCharAt(i, '0');
                        sum -= dig;
                        i--;
                    }
                }
            }
//            System.out.println(ns);
            res = Long.parseLong(ns.toString()) - n;
        }
        pw.println(res);
    }
    
    String nameIn = getClass().getSimpleName().substring(0, 1) + ".in";
    String nameOut = null;

    private void run() throws IOException {
        File input = null;
        if (nameIn != null && (input = new File(nameIn)).exists()) {
            try (
                    FileReader fr = new FileReader(input);
                    BufferedReader br = new BufferedReader(fr);) {
                load_inputs(br);
            }
        } else {
            try (
                    InputStreamReader fr = new InputStreamReader(System.in);
                    BufferedReader br = new BufferedReader(fr);) {
                load_inputs(br);
            }
        }
    }

    PrintWriter select_output() throws FileNotFoundException {
        if (nameOut != null) {
            return new PrintWriter(nameOut);
        }
        return new PrintWriter(System.out);
    }
    
}