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.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class tr1 {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, z, k;
	static long mod = (long) 1e9 + 7;
	static int[][] memo;
	static String s;
	static int[][] ad;
	static TreeMap<Long, Integer>[] gs;
	static long inf = Long.MAX_VALUE;
	static int[] color;
	static ArrayList<Integer> o;
	static char[][] g;
	static boolean[] vis, vis1;
	static long[] f;
	static int[] a;
	static int lj;
	static int[][] mat;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int t = sc.nextInt();
		while (t-- > 0) {
			long n = sc.nextLong();
			int sum = 0;
			long x = n;
			ArrayList<Integer> ar = new ArrayList<>();
			while (x > 0) {
				ar.add((int) (x % 10));
				sum += x % 10;
				x /= 10;
			}
			//Collections.reverse(ar);
			int s = sc.nextInt();
			long ans = 0;
			long power = 1;
			long power1=1;
	//		System.out.println(ar);
			for (int i = 0; i < ar.size() && sum > s; i++) {
				power = 10 * power;
				int d = ar.get(i);
				if (d != 0) {
					ans += power - d*power1;
				}
				power1 = 10 * power1;
			//	System.out.println(ans);
		//		System.out.println(ar);
				sum -= d;
				int c = 1;
				if(d!=0)
				for (int j = i + 1; j < ar.size(); j++) {
					int di = ar.get(j) + c;
					if (di == 10) {
						if(j==ar.size()-1) {
							sum -= ar.get(j);
							ar.set(j, 0);
							ar.add(1);
							break;
						}
						sum -= ar.get(j);
						ar.set(j, 0);
					} else {
						ar.set(j, di);
						sum++;
						break;
					}
				}
			}
			out.println(ans);
		}
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}