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>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> P) {
  out << '(' << P.first << ',' << P.second << ')';
  return out;
}
const ll INF64 = 8000000000000000000LL;
const ll INF = 0x3f3f3f3f;
const ll MOD = ll(1e9 + 7);
const ld PI = acos(-1);
const ld eps = 1e-9;
ll mypow(ll a, ll b) {
  ll res = 1LL;
  while (b) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
const ll maxn = 20;
ll arr[maxn];
ll dp[maxn];
void solve() {
  memset(arr, (0), sizeof(arr));
  memset(dp, (0), sizeof(dp));
  string str;
  ll a;
  cin >> str >> a;
  for (ll i = ((ll)str.size()); i < 20; i++) str = '0' + str;
  ll sum = 0;
  for (ll i = 0; i < (ll)20; i++) sum += (str[i] - '0');
  ll ans = 0;
  ll kk = 1;
  for (ll i = 19; i >= 0; i--, kk *= 10) {
    if (sum <= a) {
      cout << ans << '\n';
      return;
    }
    if (str[i] == '0') continue;
    ll tmp = i;
    sum -= (str[i] - '0');
    ans += ((('9' - str[i]) + 1) * kk);
    str[i] = '0';
    while (str[tmp - 1] == '9') {
      tmp--;
      sum -= 9;
      str[tmp] = '0';
    }
    str[tmp - 1] = (str[tmp - 1] + 1);
    sum++;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll t;
  cin >> t;
  for (ll i = 0; i < (ll)t; i++) {
    solve();
  }
  return 0;
}