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;
const long long mod = 1e9 + 7;
const long long mod2 = 998244353;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
long long oula(long long x) {
  long long res = x;
  for (register int i = 2; i <= x / i; ++i) {
    if (x % i == 0) {
      res = res / i * (i - 1);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) res = res / x * (x - 1);
  return res;
}
long long quickmod(long long a, long long n, long long m) {
  long long s = 1;
  while (n) {
    if (n & 1) {
      s = s * a % m;
    }
    a = (a * a) % m;
    n = n / 2;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void ex_gcd(long long a, long long b, long long &x, long long &y,
            long long &d) {
  if (!b) {
    d = a, x = 1, y = 0;
  } else {
    ex_gcd(b, a % b, y, x, d);
    y -= x * (a / b);
  }
}
long long inv(long long t, long long p) {
  long long d, x, y;
  ex_gcd(t, p, x, y, d);
  return d == 1 ? (x % p + p) % p : -1;
}
bool isPrime(long long x) {
  if (x == 2) return true;
  if (x % 2 == 0) return false;
  for (long long i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
inline int in() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 6;
int a[N], len;
long long n, k;
string ans = "no", tmp;
int dfs(string pre, int wei, int cost, int fg) {
  if (cost > k) return 0;
  if (wei == len + 1) {
    ans = pre;
    return 1;
  } else {
    if (fg)
      for (char i = tmp[wei - 1]; i <= '9'; i++) {
        if (i > tmp[wei - 1]) fg = 0;
        if (dfs(pre + i, wei + 1, cost + (i - '0'), fg) == 1) return 1;
      }
    else {
      for (char i = '0'; i <= '9'; i++)
        if (dfs(pre + i, wei + 1, cost + (i - '0'), fg) == 1) return 1;
    }
    return 0;
  }
}
int main() {
  int t = in();
  while (t--) {
    scanf("%lld%lld", &n, &k);
    tmp = to_string(n);
    len = (int)tmp.size();
    int bot = 0;
    if (dfs("", 1, 0, 1))
      ;
    else {
      ans = "1";
      for (register int i = 1; i <= len; ++i) ans += '0';
      tmp = '0' + tmp;
      len++;
      bot++;
    }
    string fin = "";
    for (register int i = len - 1; i >= bot; --i) {
      int tm;
      if (ans[i] < tmp[i])
        ans[i - 1]--, tm = (ans[i] - tmp[i] + 10);
      else
        tm = ans[i] - tmp[i];
      fin = to_string(tm) + fin;
    }
    while (fin.size() > 1 && fin[0] == '0') fin.erase(fin.begin());
    cout << fin << endl;
  }
  return 0;
}