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;
const int N = 20;
int t;
int n, s;
string str;
char n1[N];
char n2[N];
int a[N], b[N], c[N];
int main() {
  cin >> t;
  while (t--) {
    cin >> str >> s;
    int sum = 0, k = -1, pos = -1, flag = 1;
    for (int i = 0; i < str.size(); i++) {
      sum += str[i] - '0';
      if (sum == s && flag)
        pos = i, flag = 0;
      else if (sum > s) {
        if (pos != -1)
          k = pos;
        else
          k = i;
        break;
      }
    }
    if (sum <= s || (pos != -1 && k == -1)) {
      cout << 0 << endl;
      continue;
    }
    memset(c, 0, sizeof c);
    memset(n2, 0, sizeof n2);
    memset(n1, 0, sizeof n1);
    memset(a, 0, sizeof a);
    memset(b, 0, sizeof b);
    for (int i = k; i < str.size(); i++) n2[i - k] = str[i];
    n1[0] = '1';
    for (int i = 1; i <= strlen(n2); i++) n1[i] = '0';
    int lena = strlen(n1);
    int lenb = strlen(n2);
    for (int i = 0; i <= lena - 1; i++) a[lena - i] = int(n1[i] - '0');
    for (int i = 0; i <= lenb - 1; i++) b[lenb - i] = int(n2[i] - '0');
    int i = 1;
    while (i <= lena || i <= lenb) {
      if (a[i] < b[i]) {
        a[i] += 10;
        a[i + 1]--;
      }
      c[i] = a[i] - b[i];
      i++;
    }
    int lenc = i;
    while ((c[lenc] == 0) && (lenc > 1)) lenc--;
    for (i = lenc; i >= 1; i--) cout << c[i];
    cout << endl;
  }
  return 0;
}