#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, n, m, t, x, y, a, b, c, d, s;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    vector<long long int> vec;
    vector<long long int> po(19, 1);
    for (i = 1; i < 19; i++) po[i] = po[i - 1] * 10;
    x = n;
    long long int sum = 0, ans = 0;
    while (x > 0) {
      vec.push_back(x % 10);
      sum += (x % 10);
      x /= 10;
    }
    if (sum <= s) {
      cout << 0 << endl;
      continue;
    }
    for (i = 0; i < vec.size(); i++) {
      if (sum >= s) {
        sum = sum - vec[i];
        vec[i] = 0;
      } else
        break;
    }
    long long int r = 1;
    for (; i < vec.size(); i++) {
      x = (vec[i] + r);
      vec[i] = x % 10;
      r = x / 10;
    }
    x = 0;
    for (i = 0; i < vec.size(); i++) x += vec[i] * po[i];
    x += r * po[i];
    cout << x - n << endl;
  }
}

### Prompt

In CPP, your task is to solve the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, n, m, t, x, y, a, b, c, d, s;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    vector<long long int> vec;
    vector<long long int> po(19, 1);
    for (i = 1; i < 19; i++) po[i] = po[i - 1] * 10;
    x = n;
    long long int sum = 0, ans = 0;
    while (x > 0) {
      vec.push_back(x % 10);
      sum += (x % 10);
      x /= 10;
    }
    if (sum <= s) {
      cout << 0 << endl;
      continue;
    }
    for (i = 0; i < vec.size(); i++) {
      if (sum >= s) {
        sum = sum - vec[i];
        vec[i] = 0;
      } else
        break;
    }
    long long int r = 1;
    for (; i < vec.size(); i++) {
      x = (vec[i] + r);
      vec[i] = x % 10;
      r = x / 10;
    }
    x = 0;
    for (i = 0; i < vec.size(); i++) x += vec[i] * po[i];
    x += r * po[i];
    cout << x - n << endl;
  }
}

```