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("Ofast")
using namespace std;
const long long int N = 200043;
const long long int MOD = 1000000007;
long long int add(long long int x, long long int y) {
  x = ((x % MOD) + (y % MOD)) % MOD;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
long long int mul(long long int x, long long int y) {
  return ((x % MOD) * (y % MOD)) % MOD;
}
long long int binpow(long long int x, long long int y) {
  long long int z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
long long int inv(long long int x) { return binpow(x, MOD - 2); }
long long int divide(long long int x, long long int y) {
  return mul(x, inv(y));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, i, j;
  cin >> t;
  while (t--) {
    long long int n, s, temp;
    cin >> n >> s;
    temp = n;
    long long int ctr = 0;
    vector<long long int> ar;
    while (temp) {
      ar.push_back(temp % 10);
      ctr += temp % 10;
      temp = temp / 10;
    }
    if (ctr <= s)
      cout << 0 << endl;
    else {
      vector<long long int> ans;
      long long int carry = 0;
      for (i = 0; i < ar.size(); i++) {
        if (ctr <= s) break;
        if (ar[i] == 0 && carry == 0) {
          ans.push_back(0);
          continue;
        }
        ans.push_back(10 - ar[i]);
        carry = 1;
        ctr = ctr - ar[i] + 1;
        if (i + 1 < ar.size())
          ar[i + 1]++;
        else
          ar.push_back(1);
      }
      vector<int> fans;
      long long int ctr = 0;
      reverse(ans.begin(), ans.end());
      for (i = 0; i < ans.size(); i++) {
        if (ans[i] == 0 && ctr == 0) continue;
        cout << ans[i];
        ctr = 1;
      }
      cout << endl;
    }
  }
}