#include <bits/stdc++.h>
using namespace std;
long long int min(long long int &x, long long int &y) {
  return (x < y) ? x : y;
}
long long int max(long long int &x, long long int &y) {
  return (x > y) ? x : y;
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int modInverse(long long int b, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(b, m, &x, &y);
  if (g != 1) return -1;
  return (x % m + m) % m;
}
long long int modDivide(long long int a, long long int b, long long int m) {
  a = a % m;
  long long int inv = modInverse(b, m);
  return (inv * a) % m;
}
bool isPrime(long long int x) {
  for (long long int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  cin >> t;
  long long int c = 0;
  while (t--) {
    c++;
    long long int n, s;
    cin >> n >> s;
    long long int x = n, d = 0;
    vector<long long int> a;
    while (x != 0) {
      d += x % 10;
      a.push_back(x % 10);
      x /= 10;
    }
    if (d <= s) {
      cout << 0 << '\n';
      ;
      continue;
    }
    long long int i = a.size() - 1, b = 0;
    for (; i >= 0; i--) {
      b += a[i];
      if (b >= s) {
        b -= a[i];
        i++;
        break;
      }
    }
    if (b == 0) {
      for (long long int j = 0; j < a.size(); j++) a[j] = 0;
      a.push_back(1);
    } else {
      for (long long int j = 0; j < i; j++) a[j] = 0;
      a[i]++;
    }
    x = 0;
    for (long long int i = a.size() - 1; i >= 0; i--) x = x * 10 + a[i];
    cout << x - n << '\n';
    ;
  }
  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 int min(long long int &x, long long int &y) {
  return (x < y) ? x : y;
}
long long int max(long long int &x, long long int &y) {
  return (x > y) ? x : y;
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int modInverse(long long int b, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(b, m, &x, &y);
  if (g != 1) return -1;
  return (x % m + m) % m;
}
long long int modDivide(long long int a, long long int b, long long int m) {
  a = a % m;
  long long int inv = modInverse(b, m);
  return (inv * a) % m;
}
bool isPrime(long long int x) {
  for (long long int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  cin >> t;
  long long int c = 0;
  while (t--) {
    c++;
    long long int n, s;
    cin >> n >> s;
    long long int x = n, d = 0;
    vector<long long int> a;
    while (x != 0) {
      d += x % 10;
      a.push_back(x % 10);
      x /= 10;
    }
    if (d <= s) {
      cout << 0 << '\n';
      ;
      continue;
    }
    long long int i = a.size() - 1, b = 0;
    for (; i >= 0; i--) {
      b += a[i];
      if (b >= s) {
        b -= a[i];
        i++;
        break;
      }
    }
    if (b == 0) {
      for (long long int j = 0; j < a.size(); j++) a[j] = 0;
      a.push_back(1);
    } else {
      for (long long int j = 0; j < i; j++) a[j] = 0;
      a[i]++;
    }
    x = 0;
    for (long long int i = a.size() - 1; i >= 0; i--) x = x * 10 + a[i];
    cout << x - n << '\n';
    ;
  }
  return 0;
}

```