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;
namespace IO {
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
void setIO(string s = "") {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (s.size()) {
    setIn(s + ".inp");
    setOut(s + ".out");
  } else {
  }
}
}  // namespace IO
using namespace IO;
namespace Function {
template <typename T1, typename T2>
void amax(T1 &a, T2 b) {
  assert(!(typeid(a).name() == typeid(int).name() &&
           typeid(b).name() == typeid(long long).name()));
  if (a < b) a = b;
}
template <typename T1, typename T2>
void amin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T>
void compress(T &a) {
  sort(a.begin(), a.end());
  a.resize(unique(a.begin(), a.end()) - a.begin());
}
template <typename T1, typename T2, typename T3>
int position(T1 Begin, T2 sz, T3 val, bool type = 0) {
  if (type == 0) {
    return lower_bound(Begin, Begin + sz, val) - Begin;
  }
  return upper_bound(Begin, Begin + sz, val) - Begin;
}
template <typename T>
long long sqr(T x) {
  return 1LL * x * x;
}
template <typename T1, typename T2>
long long GCD(T1 a, T2 b) {
  return b == 0 ? a : GCD(b, a % b);
}
template <typename T1, typename T2>
long long LCM(T1 a, T2 b) {
  return 1LL * a / GCD(a, b) * b;
}
}  // namespace Function
using namespace Function;
namespace Output {
void print(int x) { cout << x << "\n"; }
void print(unsigned int x) { cout << x << "\n"; }
void print(long unsigned int x) { cout << x << "\n"; }
void print(long long x) { cout << x << "\n"; }
void print(unsigned long long x) { cout << x << "\n"; }
void print(float x) { cout << x << "\n"; }
void print(double x) { cout << x << "\n"; }
void print(long double x) { cout << x << "\n"; }
void print(char x) { cout << x << "\n"; }
void print(char *x) { cout << x << "\n"; }
void print(unsigned char x) { cout << x << "\n"; }
void print(const char *x) { cout << x << "\n"; }
void print(string x) { cout << x << "\n"; }
void print(bool x) { cout << x << "\n"; }
template <class T, class... Ts>
void print(T t, Ts... ts) {
  cout << t << " ";
  print(ts...);
}
template <typename T1, typename T2>
void print(pair<T1, T2> a) {
  print(a.first, a.second);
}
template <typename T>
void print(T a) {
  for (auto it : a) {
    print(it);
  }
}
template <class T, class... Ts>
void prine(T t, Ts... ts) {
  print(t, ts...);
  exit(0);
}
}  // namespace Output
using namespace Output;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const int INF = 1e9 + 10;
const long long INFL = 1e19;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
int main() {
  setIO();
  int T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    string N = to_string(n);
    N = '0' + N;
    int s;
    cin >> s;
    int cnt = 0;
    for (char x : N) {
      cnt += x - '0';
    }
    if (cnt <= s) {
      print(0);
      continue;
    }
    int sz = (int)N.size();
    unsigned long long res = INFL;
    unsigned long long cur = 0;
    for (int i = 0; i < sz; i++) {
      cur *= 10;
      cur += N[i] - '0';
      unsigned long long tmp = cur + 1;
      string S = to_string(tmp);
      cnt = 0;
      for (char y : S) {
        cnt += y - '0';
      }
      if (cnt > s) {
        continue;
      }
      for (int j = i + 1; j < sz; j++) {
        tmp *= 10;
      }
      amin(res, tmp - n);
    }
    print(res);
  }
  return 0;
}