#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, N = 4e5 + 10;
void solve() {
  long long n;
  cin >> n;
  long long s;
  cin >> s;
  long long sum = 0;
  vector<long long> save;
  long long dig = 0;
  long long n1 = n;
  while (n1 != 0) {
    sum += n1 % 10;
    save.push_back(n1 % 10);
    n1 = n1 / 10;
    dig++;
  }
  long long op = 0;
  long long carry = 0;
  if (sum <= s) {
    cout << op << "\n";
  } else {
    long long p = 1;
    for (long long i = 0; i < dig; i++) {
      if (save[i] == 0) {
        p = p * 10;
        continue;
      }
      sum = sum - save[i];
      carry++;
      op = op + (10 - save[i]) * p;
      p = p * 10;
      for (long long j = i + 1; j < dig; j++) {
        if (save[j] != 9) {
          save[j]++;
          sum = sum + 1;
          carry = 0;
        } else {
          save[j] = 0;
          sum = sum - 9;
        }
        if (carry == 0) break;
      }
      if (carry != 0) {
        carry = 0;
        save.push_back(1);
        dig++;
        sum++;
      }
      if (sum <= s) {
        break;
      }
    }
    cout << op << "\n";
  }
  return;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
}

### Prompt

Please create a solution in cpp 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;
const long long mod = 1e9 + 7, N = 4e5 + 10;
void solve() {
  long long n;
  cin >> n;
  long long s;
  cin >> s;
  long long sum = 0;
  vector<long long> save;
  long long dig = 0;
  long long n1 = n;
  while (n1 != 0) {
    sum += n1 % 10;
    save.push_back(n1 % 10);
    n1 = n1 / 10;
    dig++;
  }
  long long op = 0;
  long long carry = 0;
  if (sum <= s) {
    cout << op << "\n";
  } else {
    long long p = 1;
    for (long long i = 0; i < dig; i++) {
      if (save[i] == 0) {
        p = p * 10;
        continue;
      }
      sum = sum - save[i];
      carry++;
      op = op + (10 - save[i]) * p;
      p = p * 10;
      for (long long j = i + 1; j < dig; j++) {
        if (save[j] != 9) {
          save[j]++;
          sum = sum + 1;
          carry = 0;
        } else {
          save[j] = 0;
          sum = sum - 9;
        }
        if (carry == 0) break;
      }
      if (carry != 0) {
        carry = 0;
        save.push_back(1);
        dig++;
        sum++;
      }
      if (sum <= s) {
        break;
      }
    }
    cout << op << "\n";
  }
  return;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
}

```