#include <bits/stdc++.h>
using namespace std;
auto clk = clock();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(8);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, s;
    cin >> n >> s;
    long long int n1 = n;
    vector<long long int> v;
    while (n1) {
      v.push_back(n1 % 10);
      n1 /= 10;
    }
    long long int sz = v.size();
    long long int sum = 0, c = 0;
    for (int i = 0; i < sz; i++) {
      sum += v[i];
    }
    if (sum <= s) {
      cout << 0 << "\n";
    } else {
      bool b = 0;
      for (int i = 0; i < sz - 1; i++) {
        sum -= v[i];
        sum += 1;
        v[i] = 0;
        v[i + 1] += 1;
        c++;
        if (sum <= s) {
          b = 1;
          break;
        }
      }
      if (!b) {
        v[sz - 1] = 0;
        v.push_back(1);
        sz++;
      }
      long long int r = 0, p = 1;
      for (int i = 0; i < sz; i++) {
        r += v[i] * p;
        p *= 10;
      }
      cout << r - n << "\n";
    }
  }
  return 0;
}

### Prompt

Please formulate a cpp solution to 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;
auto clk = clock();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(8);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, s;
    cin >> n >> s;
    long long int n1 = n;
    vector<long long int> v;
    while (n1) {
      v.push_back(n1 % 10);
      n1 /= 10;
    }
    long long int sz = v.size();
    long long int sum = 0, c = 0;
    for (int i = 0; i < sz; i++) {
      sum += v[i];
    }
    if (sum <= s) {
      cout << 0 << "\n";
    } else {
      bool b = 0;
      for (int i = 0; i < sz - 1; i++) {
        sum -= v[i];
        sum += 1;
        v[i] = 0;
        v[i + 1] += 1;
        c++;
        if (sum <= s) {
          b = 1;
          break;
        }
      }
      if (!b) {
        v[sz - 1] = 0;
        v.push_back(1);
        sz++;
      }
      long long int r = 0, p = 1;
      for (int i = 0; i < sz; i++) {
        r += v[i] * p;
        p *= 10;
      }
      cout << r - n << "\n";
    }
  }
  return 0;
}

```