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;
vector<vector<long long> > coprime(100001);
void prime_factorization() {
  for (long long i = 2; i <= 100001; i += 2) {
    coprime[i].push_back(2);
  }
  for (long long i = 3; i <= 100001; i += 3) {
    coprime[i].push_back(3);
  }
  for (long long i = 5; i <= 50000; i += 6) {
    if (coprime[i].size() == 0) {
      for (long long j = i; j <= 100000; j += i) {
        coprime[j].push_back(i);
      }
    }
    if (coprime[i + 2].size() == 0) {
      for (long long j = i + 2; j <= 100000; j += i + 2) {
        coprime[j].push_back(i + 2);
      }
    }
  }
}
bool isprime(long long n) {
  if (n < 2) return false;
  if (n == 2 || n == 3) return true;
  if (n % 2 == 0) return false;
  if (n % 3 == 0) return false;
  for (long long i = 5; i <= sqrt(n); i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) return false;
  }
  return true;
}
long long bin_power(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) {
      res = (res * a) % 1000000007;
      n--;
    } else {
      a = (a * a) % 1000000007;
      n /= 2;
    }
  }
  return res;
}
long long p_factors(long long &n, long long p) {
  long long res = 0;
  while (n % p == 0) {
    res++;
    n = n / p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long extended_gcd(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  long long x1, y1;
  long long g = extended_gcd(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return g;
}
void simple_sieve(long long n, vector<long long> &primes) {
  if (n < 2) return;
  if (n < 3) {
    primes.push_back(2);
    return;
  }
  vector<bool> mark(n + 1, true);
  mark[2] = true;
  mark[3] = true;
  primes.push_back(2);
  primes.push_back(3);
  for (long long i = 5; i * i < n; i += 6) {
    if (mark[i]) {
      for (long long j = i * i; j < n; j += i) mark[j] = false;
    }
    if (mark[i + 2] && (i + 2) < sqrt(n)) {
      for (long long j = (i + 2) * (i + 2); j < n; j += (i + 2))
        mark[j] = false;
    }
  }
  for (long long i = 5; i < n; i += 6) {
    if (mark[i]) primes.push_back(i);
    if (mark[i + 2] && (i + 2) < n) primes.push_back(i + 2);
  }
}
void linear_sieve(long long n, vector<long long> &primes) {
  if (n < 2) return;
  if (n < 3) {
    primes.push_back(2);
    return;
  }
  vector<long long> mark(n + 1);
  for (long long i = 2; i <= n; i++) {
    if (mark[i] == 0) {
      primes.push_back(i);
      mark[i] = i;
    }
    for (long long j = 0;
         j < primes.size() && primes[j] <= mark[i] && i * primes[j] <= n; j++)
      mark[i * primes[j]] = primes[j];
  }
}
void segmented_sieve(long long n, vector<long long> &primes) {
  if (n < 2) return;
  long long limit = sqrt(n) + 1;
  simple_sieve(limit, primes);
  long long low = limit;
  long long high = 2 * limit;
  while (low < n) {
    if (high >= n) high = n + 1;
    vector<bool> mark(high - low + 2, true);
    for (long long i = 0; i < primes.size(); i++) {
      long long lolim = (low / primes[i]) * primes[i];
      if (lolim < low) lolim += primes[i];
      for (long long j = lolim; j < high; j += primes[i]) mark[j - low] = false;
    }
    for (long long j = low; j < high; j++) {
      if (mark[j - low]) primes.push_back(j);
    }
    low += limit;
    high += limit;
  }
}
void ranged_primes(long long low, long long high, vector<long long> &primes) {
  if (low < 2) low = 2;
  if (high < 2) return;
  long long lim = sqrt(high);
  vector<long long> pr;
  linear_sieve(lim, pr);
  if (pr.size() == 0) {
    if (high == 2) {
      primes.push_back(2);
      return;
    }
    if (high == 3) {
      if (low <= 2) {
        primes.push_back(2);
        primes.push_back(3);
        return;
      }
      primes.push_back(3);
      return;
    }
  }
  vector<bool> mark(high - low + 1, true);
  for (auto &i : pr) {
    long long j = i * i;
    if (j < low) {
      j = (low / i) * i;
      if (j < low) j += i;
    }
    while (j <= high) {
      mark[j - low] = false;
      j += i;
    }
  }
  for (long long i = low; i <= high; i++) {
    if (mark[i - low]) primes.push_back(i);
  }
}
long long totient(long long n) {
  long long res = n;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        n /= i;
      }
      res -= res / i;
    }
  }
  if (n > 1) res -= res / n;
  return res;
}
void phi_1_to_n(long long n, vector<long long> &phi) {
  for (long long i = 0; i <= n; i++) {
    phi[i] = i;
  }
  for (long long i = 2; i <= n; i++) {
    if (phi[i] == i) {
      for (long long j = i; j <= n; j += i) {
        phi[j] -= phi[j] / i;
      }
    }
  }
}
string division(long long a, long long b) {
  if (a == 0) return "null";
  if (b == 0) return "0";
  string s;
  if (a * b < 0)
    s = "-";
  else
    s = "";
  a = abs(a);
  b = abs(b);
  long long c = gcd(a, b);
  a = a / c;
  b = b / c;
  s += to_string(b);
  s += "/";
  s += to_string(a);
  return s;
}
long long factorial(long long n) {
  long long res = 1;
  for (long long i = 2; i <= n; i++) {
    res = (res * i) % 1000000007;
  }
  return res % 1000000007;
}
long long sumofint(long long n) {
  string s = to_string(n);
  long long sum = 0;
  for (long long i = 0; i < s.size(); i++) {
    int j = s[i];
    j -= 48;
    sum += j;
  }
  return sum;
}
int day(int m, int d) {
  int res = 0;
  for (int i = 1; i < m; i++) {
    if (i == 4 || i == 6 || i == 9 || i == 11)
      res += 30;
    else if (i == 2)
      res += 28;
    else
      res += 31;
  }
  res += d;
  return res;
}
long long fac(long long n) {
  long long res = 1;
  for (long long i = 2; i <= n; i++) {
    res = (res * i) % 1000000007;
  }
  return res % 1000000007;
}
long long modinverse(long long n) { return bin_power(n, 1000000007 - 2); }
long long solve(long long a) {
  string s = to_string(a);
  long long n = s.size();
  long long res = 0;
  for (long long i = 1; i < n; i++)
    res += 9 * pow(10, max((long long)0, i - 2));
  res += (s[0] - '1') * (pow(10, max((long long)0, n - 2)));
  if (n == 1)
    res++;
  else if (n == 2) {
    if (s[0] <= s[1]) res++;
  } else {
    long long x = (s[0] - '0') * (pow(10, n - 1) + 1);
    res += (a + 10 - x) / 10;
  }
  return res;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long tc;
  cin >> tc;
  while (tc--) {
    long long n, sum, req = 0;
    cin >> n >> sum;
    long long t = sumofint(n);
    if (t <= sum)
      cout << "0\n";
    else {
      string s = to_string(n);
      t = 0;
      for (long long i = 0; i < s.size(); i++) {
        t += (s[i] - '0');
        if (t < sum)
          req += (s[i] - '0') * pow(10, s.size() - i - 1);
        else {
          req += pow(10, s.size() - i);
          break;
        }
      }
      long long ans = req - n;
      cout << ans << endl;
    }
  }
  return 0;
}