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:
//  package com.company;
 import java.util.*;
 import java.io.*;
 import java.lang.*;

 public class Main{
     /*
      ** || ॐ श्री गणेशाय नमः ||
      ** @𝙖𝙪𝙩𝙝𝙤𝙧 𝙅𝙞𝙜𝙖𝙧_𝙉𝙖𝙞𝙣𝙪𝙟𝙞
      ** 𝙎𝙑𝙉𝙄𝙏-𝙎𝙐𝙍𝘼𝙏
      */
     public static void main(String args[]){
         PrintWriter out=new PrintWriter(System.out);
         InputReader in=new InputReader(System.in);
         TASK solver = new TASK();
        int t = in.nextInt();
        // int t=1;
         for(int i=0;i<t;i++)
         {
             solver.solve(in,out,i);
         }
         out.close();
     }
     static class TASK {
         static int mod = 998244353;
         static int sum(String s)
         {
             int sum=0;
             for(int i=0;i<s.length();i++)
             {
                 sum+=s.charAt(i)-'0';
             }
             return sum;
         }
         void solve(InputReader in, PrintWriter out, int testNumber) {
          long n = in.nextLong();
          long sum = in.nextInt();
          String s = ""+n;
          long ans=0;
          if(sum(s)<=sum)
          {
              System.out.println(ans);
              return;
          }
          long p=1;
             for (int i = 0; i < 18; ++i) {
                 long digit = (n / p) % 10;
                 long add = p * ((10 - digit) % 10);
                 n += add;
                 ans += add;
                 if (sum(String.valueOf(n)) <= sum) {
                     break;
                 }
                 p *= 10;
             }
             System.out.println(ans);
         }
     }

     static class pair{
         int x;
         int y;
         pair(int x,int y)
         {
             this.x=x;
             this.y=y;
         }

     }
     static class Maths{
         static long gcd(long a, long b) {
             if (a == 0)
                 return b;
             return gcd(b % a, a);
         }

         public  static long lcm(long a, long b)
         {
             return (a*b)/gcd(a, b);
         }

         public static long factorial(int n){
             long fact = 1;
             for(int i=1;i<=n;i++){
                 fact *= i;
             }
             return fact;
         }
     }


     static class InputReader {
         private InputStream stream;
         private byte[] buf = new byte[1024];
         private int curChar;
         private int numChars;
         private SpaceCharFilter filter;

         public InputReader(InputStream stream) {
             this.stream = stream;
         }

         public int read() {
             if (numChars == -1)
                 throw new InputMismatchException();

             if (curChar >= numChars) {
                 curChar = 0;
                 try {
                     numChars = stream.read(buf);
                 } catch (IOException e) {
                     throw new InputMismatchException();
                 }

                 if (numChars <= 0)
                     return -1;
             }
             return buf[curChar++];
         }

         public String nextLine() {
             BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
             String str = "";
             try {
                 str = br.readLine();
             } catch (IOException e) {
                 e.printStackTrace();
             }
             return str;
         }

         public int nextInt() {
             int c = read();

             while (isSpaceChar(c))
                 c = read();

             int sgn = 1;

             if (c == '-') {
                 sgn = -1;
                 c = read();
             }

             int res = 0;
             do {
                 if (c < '0' || c > '9')
                     throw new InputMismatchException();
                 res *= 10;
                 res += c - '0';
                 c = read();
             }
             while (!isSpaceChar(c));

             return res * sgn;
         }

         public long nextLong() {
             int c = read();
             while (isSpaceChar(c))
                 c = read();
             int sgn = 1;
             if (c == '-') {
                 sgn = -1;
                 c = read();
             }
             long res = 0;

             do {
                 if (c < '0' || c > '9')
                     throw new InputMismatchException();
                 res *= 10;
                 res += c - '0';
                 c = read();
             }
             while (!isSpaceChar(c));
             return res * sgn;
         }

         public double nextDouble() {
             int c = read();
             while (isSpaceChar(c))
                 c = read();
             int sgn = 1;
             if (c == '-') {
                 sgn = -1;
                 c = read();
             }
             double res = 0;
             while (!isSpaceChar(c) && c != '.') {
                 if (c == 'e' || c == 'E')
                     return res * Math.pow(10, nextInt());
                 if (c < '0' || c > '9')
                     throw new InputMismatchException();
                 res *= 10;
                 res += c - '0';
                 c = read();
             }
             if (c == '.') {
                 c = read();
                 double m = 1;
                 while (!isSpaceChar(c)) {
                     if (c == 'e' || c == 'E')
                         return res * Math.pow(10, nextInt());
                     if (c < '0' || c > '9')
                         throw new InputMismatchException();
                     m /= 10;
                     res += (c - '0') * m;
                     c = read();
                 }
             }
             return res * sgn;
         }

         public String readString() {
             int c = read();
             while (isSpaceChar(c))
                 c = read();
             StringBuilder res = new StringBuilder();
             do {
                 res.appendCodePoint(c);
                 c = read();
             }
             while (!isSpaceChar(c));

             return res.toString();
         }

         public boolean isSpaceChar(int c) {
             if (filter != null)
                 return filter.isSpaceChar(c);
             return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
         }

         public String next() {
             return readString();
         }

         public interface SpaceCharFilter {
             public boolean isSpaceChar(int ch);
         }
     }
 }