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>
const double PI = 3.1415926535897932384626433;
const int KL = 1e6;
const long long MOD = 1e9 + 7;
using namespace std;
int coun(long long i) {
  int q = 0;
  while (i != 0) {
    i /= 10;
    q++;
  }
  return q;
}
int main() {
  long long ten[20];
  ten[0] = 1;
  for (int i = 1; i < 20; i++) ten[i] = ten[i - 1] * 10;
  int t;
  scanf("%d", &t);
  while (t--) {
    long long a;
    int s;
    scanf("%lld", &a);
    scanf("%d", &s);
    int b[20];
    int w = 1;
    int c = coun(a);
    b[c] = 0;
    for (int i = c - 1; i >= 0; i--) {
      long long a1 = a / ten[i];
      long long a2 = a / ten[i + 1];
      b[i] = a1 - a2 * 10 + b[i + 1];
    }
    long long ans = 1e18 + 10, h = 0;
    if (b[0] <= s) ans = 0;
    for (int i = 0; i < c; i++) {
      long long a1 = ten[i + 1];
      long long a2 = a1 - (a % a1);
      if (b[i + 1] + 1 <= s) ans = min(ans, a2);
    }
    cout << ans << "\n";
  }
}