#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (!a) ? b : gcd(b % a, a); }
long long lcm(long long x, long long y) { return x * (y / gcd(x, y)); }
void pArr(int arr[], int s) {
  for (int i = 0; i < s; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
void pVec(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
bool isPrime(int x) {
  if (x == 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i <= (int)(pow(x, 0.5)); i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
int vBinarySearch(vector<long long> v, int l, int r, long long x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (v.at(m) == x) return m;
    if (v.at(m) < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return r + 1;
}
int binarySearch(long long arr[], long long l, long long r, long long x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (arr[m] == x) return m;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return r;
}
long long nChoosek(long long n, long long k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  int result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
long long raiseto(long long a, long long b) {
  long long m = 1;
  for (int i = 0; i < b; i++) {
    m *= a;
  }
  return m;
}
const int mod = 1e9 + 7;
bool cmp(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  }
  return a.second.first > b.second.first;
}
int sum(string s) {
  int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    sum += stoi(s.substr(i, 1));
  }
  return sum;
}
void solve() {
  string n;
  long long s, ln;
  cin >> n >> s;
  ln = stoll(n);
  long long ct = 0;
  for (int i = n.length() - 1; i >= 0 && sum(n) > s; i--) {
    if (n.at(i) != '0') {
      long long x = (10 - stoll(n.substr(i, 1))) * pow(10, n.length() - 1 - i);
      ct += x;
      ln += x;
      n = to_string(ln);
    }
  }
  cout << ct << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  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;
long long gcd(long long a, long long b) { return (!a) ? b : gcd(b % a, a); }
long long lcm(long long x, long long y) { return x * (y / gcd(x, y)); }
void pArr(int arr[], int s) {
  for (int i = 0; i < s; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
void pVec(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
bool isPrime(int x) {
  if (x == 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i <= (int)(pow(x, 0.5)); i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
int vBinarySearch(vector<long long> v, int l, int r, long long x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (v.at(m) == x) return m;
    if (v.at(m) < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return r + 1;
}
int binarySearch(long long arr[], long long l, long long r, long long x) {
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (arr[m] == x) return m;
    if (arr[m] < x)
      l = m + 1;
    else
      r = m - 1;
  }
  return r;
}
long long nChoosek(long long n, long long k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  int result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
long long raiseto(long long a, long long b) {
  long long m = 1;
  for (int i = 0; i < b; i++) {
    m *= a;
  }
  return m;
}
const int mod = 1e9 + 7;
bool cmp(pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) {
  if (a.first != b.first) {
    return a.first < b.first;
  }
  return a.second.first > b.second.first;
}
int sum(string s) {
  int sum = 0;
  for (int i = 0; i < s.length(); i++) {
    sum += stoi(s.substr(i, 1));
  }
  return sum;
}
void solve() {
  string n;
  long long s, ln;
  cin >> n >> s;
  ln = stoll(n);
  long long ct = 0;
  for (int i = n.length() - 1; i >= 0 && sum(n) > s; i--) {
    if (n.at(i) != '0') {
      long long x = (10 - stoll(n.substr(i, 1))) * pow(10, n.length() - 1 - i);
      ct += x;
      ln += x;
      n = to_string(ln);
    }
  }
  cout << ct << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

```