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.*;

public class first{
	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;
    
    public static boolean valid(long x,long y,int n,int m)
    {
    	return x>=0 && y>=0 && x<n && y<m;
    }
    
    public void go() throws IOException
    {   
    	String test =  in.readLine();
    	if(test==null || test.trim().length()==0 )
    		return ;
    	
    	 tok = new StringTokenizer(test);
    	
       int tt = Integer.parseInt(tok.nextToken());
    	 //ntok();
       
    	for(int q = 0; q < tt; q++)
    	{
		  ntok();
		  long n=lpar();
		  int s=ipar();
		  String st= String.valueOf(n);
		  int temp=0,prev=0;
		  int i;
		  long sum=0;
		  for(int j=0;j<st.length();j++)
		  {
			  sum+=st.charAt(j)-'0';
		  }
		  if(sum<=s){
			  System.out.println(0);
		    continue;
		  }
		  for( i=0;i<st.length();i++)
		  {
			  temp+=(int)(st.charAt(i)-'0');
			  if(temp+1>s)
  
			  {
				  break;
			  }
			  prev=temp;
		  }
		  
		  long ans=0,k=0, carry=0;
		  for(int j=st.length()-1;j>=i;j--)
		  {   if(st.charAt(j)-'0'==0 && carry==0){
			  ans=(st.charAt(j)-'0')*(long)Math.pow(10, k)+ans;
		       k++; 	
		  }
		  else{
			  ans=(10-((st.charAt(j)-'0')+carry))*(long)Math.pow(10, k)+ans;
			  k++;
			  carry=1;
		  }
					 
		  }
		  System.out.println(ans);
    	} 
 
        out.flush();
        in.close();
        
    }
 
    public void ntok() throws IOException
    {  String test =  in.readLine();
	if(test==null || test.trim().length()==0 )
		return ;
        tok = new StringTokenizer(test);
    }
 
    public int ipar()
    {   String test=tok.nextToken();
      if(test==null || test.trim().length()==0) 
    	  return 0;
      
        return Integer.parseInt(test);
    }
 
    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }
 
    public long lpar()
    { String test=tok.nextToken();
      if(test==null || test.trim().length()==0) 
    	  return 0;
        return Long.parseLong(test);
    }
 
    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }
 
    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }
 
    public String spar()
    { String test=tok.nextToken();
      if(test==null || test.trim().length()==0) 
    	  return "";
        return test;
    }
 
    public static void main(String[] args) throws java.lang.Exception
    {
        new first().go();
    }
    
    static class pair {
    	int f;int s;
    	public pair(int a,int b)
    	{
    		f=a;s=b;
    	}
    }

}