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;
int main() {
  long long int a, b, c, d, i, j, k, l, p, q, r, s, t, n, m;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld %lld", &n, &s);
    vector<long long int> vec, vec1;
    l = n;
    k = 0;
    d = 0;
    b = 1;
    while (n != 0) {
      vec.push_back(n % 10);
      k += n % 10;
      n = n / 10;
    }
    if (k <= s)
      printf("0\n");
    else {
      r = 0;
      for (i = 0; i < vec.size(); i++) {
        vec1.push_back(0);
        if (i == 0) {
          if (vec[i] == 0) continue;
          k -= (vec[i] - 1);
          r = 1;
        } else {
          if (vec[i] == 0) continue;
          if (r == 0) {
            k -= (vec[i] - 1);
            r = 1;
          } else
            k -= vec[i];
        }
        if (k <= s) break;
      }
      if (i == vec.size() - 1) {
        vec1.push_back(1);
        m = 0;
        b = 1;
        for (j = 0; j < vec1.size(); j++) {
          m += b * vec1[j];
          b = b * 10;
        }
      } else {
        if (vec[i + 1] == 9)
          vec1.push_back(0);
        else
          vec1.push_back(vec[i + 1] + 1);
        if (vec[i + 1] == 9)
          r = 1;
        else
          r = 0;
        for (j = i + 2; j < vec.size(); j++) {
          if (r == 1) {
            if (vec[j] == 9)
              vec1.push_back(0);
            else
              vec1.push_back(vec[j] + 1);
          } else
            vec1.push_back(vec[j]);
          if (vec[j] != 9) r = 0;
        }
        if (r == 1) vec1.push_back(1);
        m = 0;
        b = 1;
        for (j = 0; j < vec1.size(); j++) {
          m += b * vec1[j];
          b = b * 10;
        }
      }
      printf("%lld\n", m - l);
    }
  }
  return 0;
}