#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);
using namespace std;
void scans(string& str) {
  char c;
  str = "";
  scanf("%c", &c);
  if (c == '\n') scanf("%c", &c);
  while (c != '\n' && c != -1 && c != ' ') {
    str += c;
    scanf("%c", &c);
  }
}
void scanc(char& str) {
  char c;
  scanf("%c", &c);
  if (c == -1) return;
  while (c == '\n') {
    scanf("%c", &c);
  }
  str = c;
}
double acot(double x) { return PI / 2 - atan(x); }
ll LSB(ll n) { return (n & (-n)); }
template <typename T>
inline T chmin(T& a, const T& b) {
  if (a > b) a = b;
  return a;
}
template <typename T>
inline T chmax(T& a, const T& b) {
  if (a < b) a = b;
  return a;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    ll n, s, sum = 0, ans = 0;
    scanf("%lld%lld", &n, &s);
    string str = to_string(n);
    reverse((str).begin(), (str).end());
    int siz = str.size();
    for (int i = 0; i < (siz); ++i) {
      str = to_string(n);
      siz = str.size();
      sum = 0;
      for (int j = 0; j < (siz); ++j) sum += str[j] - '0';
      reverse((str).begin(), (str).end());
      if (sum <= s) {
        break;
      } else if (str[i] == '0') {
        continue;
      } else {
        ll add = 10 - (str[i] - '0');
        n += add * (ll)pow(10, i);
        ans += add * (ll)pow(10, i);
        sum -= (str[i] - '0');
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

### Prompt

Develop a solution in CPP to the problem described below:

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

### Response

```cpp
#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr ll mod = 998244353;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);
using namespace std;
void scans(string& str) {
  char c;
  str = "";
  scanf("%c", &c);
  if (c == '\n') scanf("%c", &c);
  while (c != '\n' && c != -1 && c != ' ') {
    str += c;
    scanf("%c", &c);
  }
}
void scanc(char& str) {
  char c;
  scanf("%c", &c);
  if (c == -1) return;
  while (c == '\n') {
    scanf("%c", &c);
  }
  str = c;
}
double acot(double x) { return PI / 2 - atan(x); }
ll LSB(ll n) { return (n & (-n)); }
template <typename T>
inline T chmin(T& a, const T& b) {
  if (a > b) a = b;
  return a;
}
template <typename T>
inline T chmax(T& a, const T& b) {
  if (a < b) a = b;
  return a;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    ll n, s, sum = 0, ans = 0;
    scanf("%lld%lld", &n, &s);
    string str = to_string(n);
    reverse((str).begin(), (str).end());
    int siz = str.size();
    for (int i = 0; i < (siz); ++i) {
      str = to_string(n);
      siz = str.size();
      sum = 0;
      for (int j = 0; j < (siz); ++j) sum += str[j] - '0';
      reverse((str).begin(), (str).end());
      if (sum <= s) {
        break;
      } else if (str[i] == '0') {
        continue;
      } else {
        ll add = 10 - (str[i] - '0');
        n += add * (ll)pow(10, i);
        ans += add * (ll)pow(10, i);
        sum -= (str[i] - '0');
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

```