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 long long MOD = 1e9 + 7;
const long long INF = 5e18;
const long double pi = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long double rad(long double x) { return x * pi / 180.0; }
bool isleft(pair<long long, long long> a, pair<long long, long long> b,
            pair<long long, long long> c) {
  long long det = (b.first - a.first) * (c.second - a.second) -
                  (c.first - a.first) * (b.second - a.second);
  if (det >= 0) return true;
  if (det < 0) return false;
  return false;
}
long long exp(long long a, long long b) {
  long long result = 1;
  while (b > 0) {
    if (b & 1) result = mod(result * a, MOD);
    b >>= 1;
    a = mod(a * a, MOD);
  }
  return result;
}
long long transform(vector<long long>& vet) {
  long long ans = 0;
  long long aux = 1;
  for (long long i = vet.size() - 1; i >= 0; i--) {
    ans += vet[i] * aux;
    aux *= 10;
  }
  return ans;
}
void propaga(vector<long long>& vet) {
  for (long long i = vet.size() - 1; i > 0; i--) {
    if (vet[i] == 10) {
      vet[i - 1]++;
      vet[i] = 0;
    }
  }
  if (vet[0] == 10) {
    vet.push_back(0);
    vet[0] = 1;
  }
}
void solve() {
  long long a, b;
  cin >> a >> b;
  vector<long long> vet;
  long long x = a;
  while (a > 0) {
    vet.push_back(a % 10);
    a /= 10;
  }
  reverse(vet.begin(), vet.end());
  while (true) {
    long long sum = 0;
    for (long long i = 0; i < vet.size(); i++) {
      sum += vet[i];
      if (sum > b) {
        vet[i] = 10;
        for (long long j = i + 1; j < vet.size(); j++) {
          vet[j] = 0;
        }
        propaga(vet);
        break;
      }
    }
    if (sum <= b) break;
  }
  a = transform(vet);
  cout << a - x << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  cin >> t;
  while (t--) solve();
}