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;
long long po[20];
long long cal(string s) {
  long long ss = 0;
  for (long long i = 0; i < s.size(); i++) {
    ss += s[i] - '0';
  }
  return ss;
}
void solve() {
  string n;
  long long s;
  cin >> n >> s;
  n = "0" + n;
  string temp = n;
  long long sz = n.size();
  long long k = 0, ans = 0;
  for (long long i = sz - 1; i >= 0; i--) {
    while (1) {
      long long x = cal(n);
      if (x <= s) {
        break;
      }
      if (n[i] == '9') {
        n[i] = '0';
        long long j = i - 1;
        while (j >= 0 and n[j] == '9') j--;
        for (long long h = i - 1; h > j; h--) n[h] = '0';
        n[j]++;
        break;
      }
      n[i]++;
    }
    k++;
  }
  k = 0;
  long long no = 0;
  for (long long i = n.size() - 1; i >= 0; i--) {
    no += (n[i] - '0') * po[k];
    k++;
  }
  k = 0;
  long long kkk = 0;
  for (long long i = temp.size() - 1; i >= 0; i--) {
    kkk += (temp[i] - '0') * po[k];
    k++;
  }
  cout << no - kkk << endl;
}
int main() {
  po[0] = 1;
  for (long long i = 1; i <= 19; i++) po[i] = po[i - 1] * 10;
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}