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 JAVA):

Solution:
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

public class SumDigit {
  public static void main(String[] args) throws IOException {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(System.out);
    int t, s, cur, tmp;
    long moves, n;
    char[] ns, res;

    t = in.nextInt();
    while (t-- > 0) {
      n = in.nextLong();
      s = in.nextInt();
      res = new char[19];

      cur = 0;
      ns = new char[19];
      Arrays.fill(ns, '0');
      tmp = 18;
      while (n > 0) {
        ns[tmp--] = (char)('0' + n % 10);
        cur += n % 10;
        n /= 10;
      }

      Arrays.fill(res, '0');
      moves = 0;
      if (cur > s) {
        tmp = 18;
        while (cur > s && tmp >= 0) {
          if (ns[tmp] == '0') {
            res[tmp] = (char)(moves + '0');
          }
          else {
            cur -= ns[tmp] - '0';
            res[tmp] = (char)(((10 - (ns[tmp] - '0')) % 10) + '0');
            for (int i = tmp-1; i >= 0; i--) {
              if (ns[i] != '9') {
                ns[i] = (char)(ns[i] + 1);
                cur += 1;
                break;
              }
              else {
                ns[i] = '0';
                cur -= 9;
              }
            }
          }
          tmp--;
        }
        for (int i = tmp+1; i < 19; i++) 
          pw.print(res[i]);
        pw.println();
      }
      else 
        pw.println(0);
    }
    pw.close();
  }

  static class InputReader {
    BufferedReader br;
    StringTokenizer st;
    public InputReader(InputStream inputStream) {
      br = new BufferedReader(new InputStreamReader(inputStream));
      st = null;
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}