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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void solve();
string conc(long long int a, long long int b) {
  return to_string(a) + "|" + to_string(b);
}
long long int rev(long long int x) {
  long long int ans = 0;
  while (x != 0) {
    ans = ans * 10 + (x % 10);
    x /= 10;
  }
  return ans;
}
long long int numdig(long long int x) {
  long long int ans = 0;
  while (x != 0) {
    ans++;
    x /= 10;
  }
  return ans;
}
void printvec(vector<long long int> &v) {
  for (long long int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n";
}
void printmat(vector<vector<long long int>> &mat) {
  for (long long int i = 0; i < mat.size(); i++) {
    for (long long int j = 0; j < mat[0].size(); j++) cout << mat[i][j] << " ";
    cout << "\n";
  }
}
long long int calc(string n, unordered_map<string, long long int> &u,
                   long long int i, long long int rem, bool great,
                   long long int curr) {
  if (rem < 0) return -1;
  if (i == n.size()) return curr;
  string dp = to_string(i) + " " + to_string(rem);
  long long int sp;
  if (great)
    sp = 0;
  else
    sp = n[i] - '0';
  for (long long int j = sp; j <= 9; j++) {
    bool ng = true;
    if (great == false && j == sp) ng = false;
    long long int c = calc(n, u, i + 1, rem - j, ng, curr * 10 + j);
    if (c != -1) {
      return u[dp] = c;
    }
  }
  return u[dp] = -1;
}
void solve() {
  long long int ni, ms;
  cin >> ni >> ms;
  string n = to_string(ni);
  unordered_map<string, long long int> u;
  long long int ans = calc(n, u, 0, ms, false, 0);
  if (ans == -1) {
    ans = pow(10, numdig(ni));
  }
  long long int an = ans - ni;
  cout << an << "\n";
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}