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;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
template <typename T, typename... Args>
void read(T &first, Args &...args) {
  read(first);
  read(args...);
}
template <typename T>
void write(T arg) {
  T x = arg;
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) {
    write(x / 10);
  }
  putchar(x % 10 + '0');
}
template <typename T, typename... Ts>
void write(T arg, Ts... args) {
  write(arg);
  if (sizeof...(args) != 0) {
    putchar(' ');
    write(args...);
  }
}
const long long mod = 1e9 + 7;
const int N = 0;
string ss;
int T, r;
long long n, pw[20], nc;
long long solve(long long tn) {
  vector<int> v;
  while (tn) {
    v.push_back(tn % 10);
    tn /= 10;
  }
  v.push_back(0);
  reverse(v.begin(), v.end());
  int ans = 0, p;
  long long res = 0;
  for (register int i = 0; i < (int)(v).size(); ++i) {
    ans += v[i];
    if (ans >= r) {
      p = i;
      break;
    }
  }
  for (register int i = 0; i < p; ++i) {
    res = res * 10 + v[i];
  }
  res += 1;
  res *= pw[(int)(v).size() - p];
  return res;
}
bool check(long long tn) {
  int ans = 0;
  while (tn) {
    ans += tn % 10;
    tn /= 10;
  }
  return ans > r;
}
int main() {
  cin >> T;
  pw[0] = 1;
  for (register int i = 1; i <= 18; ++i) {
    pw[i] = pw[i - 1] * 10LL;
  }
  while (T--) {
    cin >> n >> r;
    nc = n;
    while (check(n)) {
      n = solve(n);
    }
    cout << n - nc << endl;
  }
  return 0;
}