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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class D {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int T = Integer.parseInt(br.readLine());
		for (int c = 0; c < T; c++) {
			StringTokenizer st = new StringTokenizer(br.readLine(), " ");
			int[] n = new int[19];
			String str = st.nextToken();
			for (int i = 0, j = 19 - str.length(); i < str.length(); i++, j++) {
				n[j] = str.charAt(i) - '0';
			}
			int s = Integer.parseInt(st.nextToken());
			int digit = 0;
			for (int i = 0; i < n.length; i++) {digit += n[i];}
			int p = 18;
			while (p >= 1 && n[p] != ' ' && digit > s) {
				digit -= n[p]; n[p] = 0;
				int t = p - 1;
				while (n[t] == 9) {n[t] = 0; digit -= 9; t--;}
				n[t]++; digit++;
				p--;
			}
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < 19; i++) {sb.append(n[i]);}
			long start = Long.parseLong(str);
			long end = Long.parseLong(sb.toString().trim());
			bw.write(String.valueOf(end - start));
			bw.newLine();
		}
		bw.close();
	}

}