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 modPower(long long num, long long r) {
  if (r == 0) return 1;
  if (r == 1) return num % 1000000007;
  long long ans = modPower(num, r / 2) % 1000000007;
  if (r % 2 == 0) {
    return (ans * ans) % 1000000007;
  }
  return (((ans * ans) % 1000000007) * num) % 1000000007;
}
long long nCr(long long n, long long r) {
  long long res = 1;
  if (r > n - r) {
    r = n - r;
  }
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int pos(int a) {
  if (a < 0)
    return (-1) * a;
  else
    return a;
}
unsigned long long highestPowerof2(unsigned long long n) {
  unsigned long long p = (unsigned long long)log2(n);
  return (unsigned long long)pow(2, p);
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<int> fprint(vector<int> A, int n) {
  vector<int> fprint;
  for (int i = 0; i < n - 1; i++) {
    fprint.push_back(A[i] + A[i + 1]);
  }
  sort(fprint.begin(), fprint.end());
  return fprint;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long grr;
  cin >> grr;
  while (grr--) {
    long long count = 0;
    long long n, s;
    cin >> n >> s;
    long long c = n, rev = 0;
    long long x = 10;
    long long sum = 0, sum2 = 0, len = 0;
    while (c > 0) {
      sum += c % 10;
      rev = rev * 10 + c % 10;
      len++;
      c = c / 10;
    }
    if (sum <= s)
      cout << 0 << "\n";
    else {
      sum2 = 0;
      while (sum2 + rev % 10 < s && rev > 0) {
        count++;
        sum2 += rev % 10;
        rev /= 10;
      }
      long long x = len - count, y = 1;
      while (x--) {
        y *= 10;
      }
      n = n % y;
      x = 10;
      while (n / x != 0) {
        x *= 10;
      }
      cout << x - n << "\n";
    }
  }
}