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.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class DigitSum {
    public static void main(String[] args) throws IOException {
        try (BufferedReader console = new BufferedReader(new InputStreamReader(System.in))) {
            int t = Integer.parseInt(console.readLine());
            for (int i = 0; i < t; ++i) {
                String[] ab = console.readLine().split(" ");
                long n = Long.parseLong(ab[0]);
                int s = Integer.parseInt(ab[1]);
                System.out.println(solve(n,s));
            }

        }
    }

    private static long solve(long n, int s) {
        int sum = 0;
        for (long n2 = n; n2 > 0; n2 /= 10)
            sum += n2 % 10;
        if (sum <= s)  return 0;
        long d = n % 10;
        long out = 10 - d;
        sum -= d;
        for (long n2 = n / 10, exp = 10; n2 > 0; n2 /= 10, exp *= 10) {
            d = (n2 % 10) + 1;
            if (d == 10) {
                sum -= 9;
                continue;
            } else {
                ++sum;
                if (sum <= s)
                    break;
            }
            out += (10 - d) * exp;
            sum -= d;
        }
        return out;
    }
}