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.util.*;
import java.io.*;

public class cf {

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while (t-- > 0) {
			long n = sc.nextLong();
			int s = sc.nextInt();
			int k = sod(n);
			long ans = 0;
			long m = 1;
			if (k <= s) {
				pw.println(0);
			} else {
				while (true) {
					if (sod(n / m) + 1 <= s) {
						break;
					} else {
						ans += m * (9 - ((n / m) % 10));
					}
					m *= 10;
				}
				pw.println(ans + 1);
			}
		}
		pw.close();
	}

	static long pow(long a, long e) {
		long res = 1;
		while (e > 0) {
			if ((e & 1) == 1)
				res *= a;
			a *= a;
			e >>= 1;
		}
		return res;
	}

	static int sod(long n) {
		int a = 0;
		while (n > 0) {
			a += n % 10;
			n /= 10;
		}
		return a;
	}

	static PrintWriter pw = new PrintWriter(System.out);

	public static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return x + " " + y;
		}

		public boolean equals(Object o) {
			if (o instanceof pair) {
				pair p = (pair) o;
				return p.x == x && p.y == y;
			}
			return false;
		}

		public int hashCode() {
			return new Double(x).hashCode() * 31 + new Double(y).hashCode();
		}

		public int compareTo(pair other) {
			if (this.x == other.x) {
				return Long.compare(this.y, other.y);
			}
			return Long.compare(this.x, other.x);
		}
	}

	public static class tuble implements Comparable<tuble> {
		int x;
		int y;
		int z;

		public tuble(int x, int y, int z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return x + " " + y + " " + z;
		}

		public int compareTo(tuble other) {
			if (this.x == other.x) {
				if (this.y == other.y)
					return this.z - other.z;
				return this.y - other.y;
			} else {
				return this.x - other.x;
			}
		}
	}

	static class SegmentTree {
		int size;
		int[] st;

		public String toString() {
			return Arrays.toString(st);
		}

		void init(int n) {
			size = 1;
			while (size < n)
				size *= 2;
			st = new int[2 * size];
		}

		void build(int[] arr) {
			build(arr, 0, 0, size);
		}

		void build(int[] arr, int x, int lx, int rx) {
			if (rx - lx == 1) {
				if (lx < arr.length) {
					st[x] = arr[lx];
				}
				return;
			}
			int m = (lx + rx) >> 1;
			build(arr, 2 * x + 1, lx, m);
			build(arr, 2 * x + 2, m, rx);
			st[x] = st[2 * x + 1] + st[2 * x + 2];
		}

		void set(int i, int v) {
			set(i, v, 0, 0, size);
		}

		void set(int i, int v, int x, int l, int r) {
			if (r - l == 1) {
				st[x] = v;
				return;
			}
			int m = (l + r) >> 1;
			if (i < m) {
				set(i, v, 2 * x + 1, l, m);
			} else {
				set(i, v, 2 * x + 2, m, r);
			}
			st[x] = st[2 * x + 1] + st[2 * x + 2];
		}

		long get(int l, int r) {
			return get(l, r + 1, 0, 0, size);
		}

		long get(int l, int r, int x, int lx, int rx) {
			if (lx >= r || rx <= l) {
				return 0;
			} else if (lx >= l && rx <= r) {
				return st[x];
			}
			int m = (lx + rx) >> 1;
			return get(l, r, 2 * x + 1, lx, m) + get(l, r, 2 * x + 2, m, rx);
		}

		int find(int idx) {
			return find(idx, 0);
		}

		int find(int idx, int node) {
			if (node >= size - 1) {
				return node - size + 1;
			}
//			pw.print(node + " ");
			if (st[node * 2 + 1] > idx) {
				return find(idx, node * 2 + 1);
			} else {
				return find(idx - st[node * 2 + 1], node * 2 + 2);
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public boolean hasNext() {
			// TODO Auto-generated method stub
			return false;
		}

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

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

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

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

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

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

	}
}