#include <bits/stdc++.h>
using namespace std;
void setIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long double PI = 4 * atan((long double)1);
const int INF = 1e9 + 7;
const long long _INF = 1e18 + 7;
int main() {
  setIO();
  int t;
  cin >> t;
  while (t--) {
    vector<int> v, a;
    bool sp = false;
    long long n, s, sd = 0;
    cin >> n >> s;
    long long x = n;
    while (x) {
      v.emplace_back(x % 10);
      sd += (x % 10);
      x /= 10;
    }
    reverse(v.begin(), v.end());
    if (sd <= s) {
      cout << "0\n";
      continue;
    }
    int i;
    sd = 0;
    for (i = 0; i < (int)v.size(); i++) {
      if (sd + v[i] >= s) {
        if (!i) {
          sp = true;
          break;
        }
        a[i - 1]++;
        break;
      }
      sd += v[i];
      a.emplace_back(v[i]);
    }
    if (sp) {
      x = 1;
      for (int j = 0; j < (int)v.size(); j++) x *= 10;
      cout << x - n << endl;
    } else {
      long long ans = 0;
      x = 1;
      for (int j = 0; j < (int)v.size(); j++) {
        if ((int)v.size() - j <= i) {
          ans += (a[(int)v.size() - j - 1] * x);
        }
        x *= 10;
      }
      cout << ans - n << endl;
    }
  }
}

### Prompt

Your challenge is to write 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;
void setIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
const long double PI = 4 * atan((long double)1);
const int INF = 1e9 + 7;
const long long _INF = 1e18 + 7;
int main() {
  setIO();
  int t;
  cin >> t;
  while (t--) {
    vector<int> v, a;
    bool sp = false;
    long long n, s, sd = 0;
    cin >> n >> s;
    long long x = n;
    while (x) {
      v.emplace_back(x % 10);
      sd += (x % 10);
      x /= 10;
    }
    reverse(v.begin(), v.end());
    if (sd <= s) {
      cout << "0\n";
      continue;
    }
    int i;
    sd = 0;
    for (i = 0; i < (int)v.size(); i++) {
      if (sd + v[i] >= s) {
        if (!i) {
          sp = true;
          break;
        }
        a[i - 1]++;
        break;
      }
      sd += v[i];
      a.emplace_back(v[i]);
    }
    if (sp) {
      x = 1;
      for (int j = 0; j < (int)v.size(); j++) x *= 10;
      cout << x - n << endl;
    } else {
      long long ans = 0;
      x = 1;
      for (int j = 0; j < (int)v.size(); j++) {
        if ((int)v.size() - j <= i) {
          ans += (a[(int)v.size() - j - 1] * x);
        }
        x *= 10;
      }
      cout << ans - n << endl;
    }
  }
}

```