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>
long long mod = 1000000007;
void normalize(long long &a) { a = (a + mod) % mod; }
long long modmul(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  normalize(a);
  normalize(b);
  return (a * b) % mod;
}
long long modadd(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  normalize(a);
  normalize(b);
  return (a + b) % mod;
}
long long modsub(long long a, long long b) {
  a = a % mod;
  b = b % mod;
  normalize(a);
  normalize(b);
  return (a - b + mod) % mod;
}
long long me(long long x, long long n) {
  x %= mod;
  if (n == 0) return 1;
  long long u = me(x, n / 2) % mod;
  u = (u * u) % mod;
  if (n % 2) u = (u * x) % mod;
  return u;
}
long long ipow(long long x, long long n) {
  if (n == 0) return 1;
  long long u = ipow(x, n / 2);
  u = (u * u);
  if (n % 2) u = (u * x);
  return u;
}
long long logb(long long a, long long b) {
  long long ans = 0;
  while (a >= b) {
    a /= b;
    ans++;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool isprime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  if (n == 1) return false;
  return true;
}
using namespace std;
long long a[200005];
long long sumOfDigit(long long n) {
  long long s = 0;
  while (n > 0) {
    s += n % 10;
    n /= 10;
  }
  return s;
}
void solve() {
  long long n;
  cin >> n;
  ;
  long long s;
  cin >> s;
  ;
  long long t = n, sum = sumOfDigit(n), po = 1;
  while (sumOfDigit(t) > s) {
    long long d = (t % (po * 10)) / po;
    if (d != 0) t = t + (10 - d) * po;
    po *= 10;
  }
  cout << t - n;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
    cout << "\n";
  }
  return 0;
}