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 M = 1e9 + 5;
long long mod(long long x) { return ((x % M + M) % M); }
long long add(long long a, long long b) { return mod(mod(a) + mod(b)); }
long long mul(long long a, long long b) { return mod(mod(a) * mod(b)); }
long long modPow(long long a, long long b) {
  if (b == 0) return 1LL;
  if (b == 1) return a % M;
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = mul(res, a);
    a = mul(a, a);
    b = b / 2;
  }
  return res;
}
long long check(long long n, long long ok) {
  long long ans = n + ok;
  long long total = 0;
  while (ans) {
    total += (ans % 10);
    ans /= 10;
  }
  return total;
}
void solve() {
  long long n, s;
  cin >> n >> s;
  long long a = n;
  long long total = 0;
  while (a) {
    total += (a % 10);
    a /= 10;
  }
  if (total <= s) {
    cout << 0 << "\n";
    return;
  }
  long long b = n;
  long long ok = 0;
  long long p = 1;
  long long tot = 0;
  long long ss = 0;
  while (b && total > s) {
    long long last = b % 10;
    total -= last;
    if (last) {
      ok += (long long)(p * (10 - last));
      b /= 10;
      b += 1;
      ss = b;
      while (ss) {
        tot += (ss % 10);
        ss /= 10;
      }
      if (b == 1) {
        b = 0;
        break;
      }
      total = tot;
    } else {
      b /= 10;
    }
    p *= (long long)10;
    if (check(n, ok) <= s) {
      cout << ok << "\n";
      return;
    }
  }
  cout << ok << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(10);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}