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 int M = LLONG_MAX, d1_gcd, x1_gcd, y1_gcd;
long long int modulo_expo(long long int x, long long int n) {
  if (x == 0 || x == 1) {
    return x;
  }
  long long int ans = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      ans = ((ans % M) * (x % M)) % M;
    }
    x = ((x % M) * (x % M)) % M;
    n /= 2;
  }
  return ans;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
void extd_gcd(long long int a, long long int b) {
  if (b == 0) {
    d1_gcd = a;
    x1_gcd = 1;
    y1_gcd = 0;
  } else {
    extd_gcd(b, a % b);
    long long int temp = x1_gcd;
    x1_gcd = y1_gcd;
    y1_gcd = temp - ((a / b) * y1_gcd);
  }
}
void carry(string &num, long long int i) {
  if (i == 0 && num[i] == '9') {
    num[i] = '0';
    num = "1" + num;
    return;
  }
  if (num[i] < '9') {
    num[i]++;
    return;
  } else {
    num[i] = '0';
    carry(num, i - 1);
  }
  return;
}
unsigned long long int to_num(string a) {
  unsigned long long int ans = 0, k = 1;
  for (int i = a.size() - 1; i >= 0; i--) {
    ans += (((int)(a[i] - '0')) * k);
    k *= 10;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  cin >> t;
  while (t--) {
    string s, num;
    unsigned long long int ans = 0;
    long long int n, k = 0, i = 0;
    cin >> s >> n;
    num = s;
    while (i < s.size() && k + ((int)(s[i] - '0')) <= n) {
      k += ((int)(s[i] - '0'));
      i++;
    }
    if (i != s.size()) {
      while (i > 0 && k == n) {
        i--;
        k -= ((int)(s[i] - '0'));
      }
      for (int l = s.size() - 1; l >= i; l--) {
        num[l] = '0';
      }
      if (num[0] == '0') {
        num = ("1" + num);
        s = ("0" + s);
      } else {
        carry(num, i - 1);
        if (num.size() != s.size()) {
          s = ("0" + s);
        }
      }
      ans = to_num(num) - to_num(s);
    }
    cout << ans << endl;
  }
  return 0;
}