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.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public final class CF
{
    public static void main(String[]args)throws IOException
    {
        FastReader ob=new FastReader();
        int t=ob.nextInt();
        StringBuffer sb=new StringBuffer();
        while(t-->0)
        {
               long n=ob.nextLong();long n1=n;
               long s=ob.nextInt();
               ArrayList<Long> a=new ArrayList<>();
               long sum=0;
               while(n!=0)
               {
                    a.add(n%10);
                    sum+=n%10;
                    n/=10;
               }
               Collections.reverse(a);
               if(sum<=s)
               System.out.println("0");
               else 
               {
                    int c=0,pos=-1;
                    for(int i=0;i<a.size();i++)
                    {
                         if(a.get(i)+1+c<=s)
                         {
                              if(a.get(i)!=9)
                              pos=i;
                         }
                         else
                         break;
                         c+=a.get(i);
                         //System.out.println(c);
                    }
                    if(pos==-1)
                    {
                         int num[]=new int[a.size()+1];
                         num[0]=1;
                         StringBuffer ans=new StringBuffer();
                         for(int i=0;i<num.length;i++)
                         ans.append(num[i]);
                        System.out.println(Long.valueOf(ans.toString())-n1);
                    }
                    else
                    {
                         long num[]=new long[a.size()];
                         for(int i=0;i<pos;i++)
                         num[i]=a.get(i);
                         num[pos]=a.get(pos)+1;
                         StringBuffer ans=new StringBuffer();
                         for(int i=0;i<num.length;i++)
                         ans.append(num[i]);
                         System.out.println(Long.valueOf(ans.toString())-n1);
                    }
               }
        }
        System.out.println(sb);
    }
}
class FastReader {
    BufferedReader br;
    StringTokenizer st;
    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e)  {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    public String nextLine()
    {
        String s="";
        try {
        s=br.readLine();
        } catch (IOException e)  {
                e.printStackTrace();
            }
        return s;
    }
    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}