#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long MM = 998244353;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 5;
const long long N = 5e6 + 4;
long long mul(long long x, long long y) { return (x * 1ll * y); }
long long add(long long x, long long y) {
  x += y;
  while (x >= mod) x -= mod;
  while (x < 0) x += mod;
  return x;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
long long digsum(long long n) {
  long long res = 0;
  while (n) {
    long long d = n % 10;
    n /= 10;
    res += d;
  }
  return res;
}
void solve() {
  long long n, s;
  cin >> n >> s;
  long long sum = digsum(n);
  if (sum <= s) {
    cout << "0\n";
    return;
  }
  auto isOK = [&](long long N) {
    long long sum2 = digsum(N);
    if (sum2 <= s) return 1;
    return 0;
  };
  long long fans = INF;
  for (long long i = 18; i >= 1; i--) {
    long long pow = power(10, i);
    long long rem = n / pow;
    rem++;
    long long ans = rem * pow;
    if (isOK(ans)) {
      long long diff = ans - n;
      amin(fans, diff);
    }
  }
  cout << fans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}

### Prompt

Construct a Cpp code solution to the problem outlined:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long MM = 998244353;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 5;
const long long N = 5e6 + 4;
long long mul(long long x, long long y) { return (x * 1ll * y); }
long long add(long long x, long long y) {
  x += y;
  while (x >= mod) x -= mod;
  while (x < 0) x += mod;
  return x;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
long long digsum(long long n) {
  long long res = 0;
  while (n) {
    long long d = n % 10;
    n /= 10;
    res += d;
  }
  return res;
}
void solve() {
  long long n, s;
  cin >> n >> s;
  long long sum = digsum(n);
  if (sum <= s) {
    cout << "0\n";
    return;
  }
  auto isOK = [&](long long N) {
    long long sum2 = digsum(N);
    if (sum2 <= s) return 1;
    return 0;
  };
  long long fans = INF;
  for (long long i = 18; i >= 1; i--) {
    long long pow = power(10, i);
    long long rem = n / pow;
    rem++;
    long long ans = rem * pow;
    if (isOK(ans)) {
      long long diff = ans - n;
      amin(fans, diff);
    }
  }
  cout << fans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}

```