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;
long long int power(int i) {
  long long int x = 1;
  while (i--) {
    x = x * 10;
  }
  return x;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, p;
    int s;
    cin >> n >> s;
    p = n;
    int a[19], b[19];
    for (int i = 0; i < 19; i++) {
      a[i] = n / power(18 - i);
      n = n - a[i] * power(18 - i);
    }
    int x = 0;
    for (int i = 0; i < 19; i++) {
      x = x + a[i];
    }
    if (s >= x)
      cout << 0 << endl;
    else {
      int i = 0;
      for (i = 0; i < 19; i++) {
        if (s > a[i]) {
          s = s - a[i];
        } else
          break;
      }
      int j;
      int c[19 - i];
      for (j = 0; j < 19 - i; j++) {
        if (a[18 - j] != 0) break;
        c[j] = a[18 - j];
      }
      c[j] = 10 - a[18 - j];
      int t = j + 1;
      for (int p = 17 - j; p >= i; p--) {
        c[t] = 9 - a[p];
        t++;
      }
      int initial0 = 0;
      for (int f = 18 - i; f >= 0; f--) {
        if (c[f] != 0)
          break;
        else
          initial0++;
      }
      for (int f = 18 - i - initial0; f >= 0; f--) {
        cout << c[f];
      }
      cout << endl;
    }
  }
}