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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5;
long long spf[N], spf1[N];
void sieve() {
  for (int i = 1; i < N; i++) spf[i] = i;
  for (int i = 2; i * i < N; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < N; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}
long long ncr(long long a, long long b) {
  long long k = 1;
  if (b > a) swap(a, b);
  for (long long i = 1; i <= b; i++) {
    k = ((k * (a + i)));
    k = k / i;
  }
  return k;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
long long nCrModPFermat(long long n, long long r, long long p) {
  if (r == 0) return 1;
  long long fac[n + 1];
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void solve() {
  long long int n, k = 0, sum = 0, sum1 = 0, m = 1, l = 0, r = 0, q = 0, x = 0,
                   y = 0, z = 0, lcm, a1, b1 = 0, i = 0, j = 0, n1, n2, n0, u,
                   m1, e = -1, o = -1, c1, d1, c, k1, k2, p, b, second;
  bool flag = 0, first = 0;
  cin >> n >> second;
  long long a[20] = {0};
  m = n;
  i = 0;
  for (i = 0; i < 20; i++) a[i] = 0;
  i = 0;
  while (m > 0 && i < 20) {
    a[i] = m % 10;
    m /= 10;
    i++;
  }
  k = 0;
  for (i = 0; i < 20; i++) k += a[i];
  i = 0;
  while (k > second) {
    if (a[i] > 0) {
      a[i] = 0;
      while (a[i] == 0) {
        i++;
        a[i]++;
        if (a[i] == 10) a[i] == 0;
      }
    } else
      i++;
    k = 0;
    for (j = 0; j < 20; j++) k += a[j];
  }
  l = 1;
  m = 0;
  for (i = 0; i < 20; i++) {
    m += a[i] * l;
    l *= 10;
  }
  cout << m - n << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}