#include <bits/stdc++.h>
using namespace std;
long long Ans;
long long pos = 0;
long long s[55];
long long a, b;
void init() {
  Ans = 0;
  memset(s, 0, sizeof(s));
  pos = 0;
  while (a) {
    s[++pos] = a % 10;
    a /= 10;
  }
}
bool Check() {
  long long res = 0;
  for (long long i = 0; i < 20; i++) {
    res += s[i];
    if (res > b) return false;
  }
  return true;
}
long long Copy;
void Print() {
  long long r;
  if (s[pos + 1] == 0)
    r = pos;
  else
    r = pos + 1;
  long long sum = 0;
  for (long long i = r; i >= 1; i--) sum = sum * 10 + s[i];
  cout << sum - Copy << endl;
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    Copy = a;
    init();
    long long nxt = 1;
    for (long long i = 1; i <= pos; i++) {
      if (Check()) {
        Print();
        break;
      }
      if (s[i] == 0) {
        continue;
      }
      if (i == pos) {
        s[i] = 0;
        s[i + 1] = 1;
        Print();
        break;
      }
      s[i] = 0;
      s[i + 1]++;
      long long p = i + 1;
      while (p <= pos && s[p] == 10) {
        s[p] = 0;
        s[p + 1]++;
        p++;
      }
      if (p == pos) {
        if (Check())
          Print();
        else {
          s[p] = 0;
          s[p + 1] = 1;
          Print();
        }
        break;
      }
      nxt *= 10;
    }
  }
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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;
long long Ans;
long long pos = 0;
long long s[55];
long long a, b;
void init() {
  Ans = 0;
  memset(s, 0, sizeof(s));
  pos = 0;
  while (a) {
    s[++pos] = a % 10;
    a /= 10;
  }
}
bool Check() {
  long long res = 0;
  for (long long i = 0; i < 20; i++) {
    res += s[i];
    if (res > b) return false;
  }
  return true;
}
long long Copy;
void Print() {
  long long r;
  if (s[pos + 1] == 0)
    r = pos;
  else
    r = pos + 1;
  long long sum = 0;
  for (long long i = r; i >= 1; i--) sum = sum * 10 + s[i];
  cout << sum - Copy << endl;
}
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    Copy = a;
    init();
    long long nxt = 1;
    for (long long i = 1; i <= pos; i++) {
      if (Check()) {
        Print();
        break;
      }
      if (s[i] == 0) {
        continue;
      }
      if (i == pos) {
        s[i] = 0;
        s[i + 1] = 1;
        Print();
        break;
      }
      s[i] = 0;
      s[i + 1]++;
      long long p = i + 1;
      while (p <= pos && s[p] == 10) {
        s[p] = 0;
        s[p + 1]++;
        p++;
      }
      if (p == pos) {
        if (Check())
          Print();
        else {
          s[p] = 0;
          s[p + 1] = 1;
          Print();
        }
        break;
      }
      nxt *= 10;
    }
  }
  return 0;
}

```