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>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
using namespace std;
auto clk = clock();
const long double pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const long long prost = 239;
const long long btc = 30;
const long double eps = 1e-10;
const long long INF = (long long)(1e18 + 239);
const int BIG = (int)(1e9 + 239);
const int MOD = 998244353;
const long long MOD2 = (long long)MOD * (long long)MOD;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
const int mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n, s;
    cin >> n >> s;
    string str, ans;
    str = to_string(n);
    long long sz = str.length(), sum = 0, flag = 0, i, j;
    for (i = 0; str[i]; i++) {
      char ch = str[i];
      int dig = ch - '0';
      ans.push_back(ch);
      if (sum + dig > s) {
        j = i;
        ans[i] = '0';
        flag = 1;
        break;
      } else {
        sum += dig;
      }
    }
    int done = 0;
    if (flag == 0) {
      cout << 0 << '\n';
      continue;
    } else {
      ans[i] = '0';
      i--;
      if (i >= 0) {
        while (i >= 0) {
          if (ans[i] - '0' < 9) {
            if (sum < s) {
              ans[i]++;
              sum++;
              done = 1;
              break;
            } else {
              sum -= (ans[i] - '0');
              ans[i] = '0';
            }
          } else {
            sum -= (ans[i] - '0');
            ans[i] = '0';
          }
          i--;
        }
      }
      if (i < 0 and done == 0) {
        ans = "1" + ans;
      }
      j++;
      for (; str[j]; j++) {
        ans.push_back('0');
      }
    }
    long long ansll;
    ansll = stoll(ans);
    cout << ansll - n << '\n';
  }
  return 0;
}