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;
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
const int inf = 0x3f3f3f3f;
const int rinf = 0xc0c0c0c0;
const LL MOD = 1e9 + 7;
const LL LMAX = 0x7fffffffffffffff;
const LL LMIN = 0x8000000000000000;
using std::cin;
using std::cout;
using std::endl;
using std::vector;
template <typename T>
void print(vector<vector<T>> a) {
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < a[i].size(); ++j)
      cout << a[i][j] << (j == ((int)a[i].size()) - 1 ? '\n' : ' ');
  }
}
template <typename T>
void print(T *a, int len) {
  for (int i = 0; i < len; ++i) cout << a[i] << " ";
  cout << endl;
}
template <typename T>
void print(T **a, int row, int col) {
  for (int i = 0; i < row; ++i) {
    for (int j = 0; j < col; ++j)
      cout << a[i][j] << (j == col - 1 ? '\n' : ' ');
  }
}
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f * x;
}
void write(int a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) write(a / 10);
  putchar(a % 10 + 48);
}
void upt(const LL n, LL &tot) {
  tot = 0;
  for (LL i = 0; i < 18; ++i) {
    LL bit = (n / LL(pow(10LL, i))) % 10;
    tot += bit;
  }
}
void solve() {
  LL n, s;
  cin >> n >> s;
  LL res = 0, tot = 0;
  upt(n, tot);
  for (LL i = 0; i < 18; ++i) {
    if (tot <= s) break;
    LL bit = (n / LL(pow(10LL, i))) % 10;
    if (bit == 0) continue;
    LL dlt = (10LL - bit) * pow(10LL, i);
    res += dlt, n += dlt;
    upt(n, tot);
  }
  cout << res << endl;
}
int main() {
  int t = read();
  while (t--) solve();
  return 0;
}