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;
const long long int mod = 1000000000 + 7;
const long long int N = 10000000 + 6;
string lltst(long long int n) {
  string st = "";
  while (n > 0) {
    st.push_back((n % 10) + '0');
    n /= 10;
  }
  reverse(st.begin(), st.end());
  return st;
}
long long int stll(string st) {
  long long int n = 0;
  long long int po = 1;
  for (int j = st.size() - 1; j >= 0; j--) {
    n = (st[j] - '0') * po + n;
    po = po * 10;
  }
  return n;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int temp = n;
    long long int sum = 0;
    while (n > 0) {
      int r = n % 10;
      sum += r;
      n /= 10;
    }
    if (sum <= k) {
      cout << 0 << '\n';
      continue;
    }
    string st = lltst(temp);
    int j = -1;
    int curr = 0;
    long long int rem = sum - k;
    for (int i = st.size() - 1; i >= 0; i--) {
      curr = curr + st[i] - '0';
      if (curr > rem && i - 1 >= 0 && st[i - 1] != '9') {
        j = i;
        break;
      }
    }
    if (j - 1 <= -1) {
      int l = st.size();
      string str = "1";
      while (l--) str.push_back('0');
      long long int big = stll(str);
      long long int small = stll(st);
      cout << big - small << '\n';
    } else {
      string str = "";
      for (int i = 0; i < st.size(); i++) {
        if (i < j - 1)
          str.push_back(st[i]);
        else if (i == j - 1)
          str.push_back(st[i] + 1);
        else
          str.push_back('0');
      }
      long long int big = stll(str);
      long long int small = stll(st);
      cout << big - small << '\n';
    }
  }
  return 0;
}