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 Problem_D {
	static long N, ans;
	static int S;
	static char[] n_str, c;

	public static void solve(int idx, int sum, boolean flag) {
		if (sum > S) {
			return;
		}
		if (idx == c.length) {
			ans = Math.min(ans, Long.parseLong(new String(c)) - N);
			return;
		}
		if (flag) {
			c[idx] = '0';
			solve(idx + 1, sum, true);
			return;
		}
		c[idx] = n_str[idx];
		solve(idx + 1, sum + c[idx] - 48, false);
		if (n_str[idx] < '9') {
			c[idx] = (char)(n_str[idx] + 1);
			solve(idx + 1, sum + c[idx] - 48, true);
		}
	}

	public static void main(String[] args) {
		InputReader in = new InputReader();
		StringBuilder out = new StringBuilder();

		int T = in.nextInt();
		while (T-- > 0) {
			N = Long.parseLong(in.next());
			S = in.nextInt();
			if (N == 1000000000000000000L) {
				out.append("0\n");
				continue;
			}
			n_str = String.valueOf(N).toCharArray();
			long tmp = 1;
			for (int i = 0; i < n_str.length; i++) {
				tmp *= 10;
			}
			ans = tmp - N;
			c = new char[n_str.length];
			solve(0, 0, false);
			out.append(ans).append('\n');
		}

		System.out.print(out);
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer st;

		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(nextLine());
			}
			return st.nextToken();
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}