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.io.*;
	import java.math.*;
	import java.awt.geom.*;
	 
	import static java.lang.Math.*;
	 
	 public class Solution implements Runnable {
		
		 long mod1=(long)1e9+7;
		 int mod2=998244353;
	     
		 public void solve() throws Exception {
			 int t=sc.nextInt();
			 while(t-->0)
			 {
				long n=sc.nextLong();
				long nn=n;
				int sum=sc.nextInt();
				int initial=sumdigit(n);
				String str=Long.toString(n);
				if(initial<sum)
				{
					out.println(0);
					continue;
				}
				int s=initial;
				int pos=str.length();
				long r=1;
				
				while(s>sum)
				{
					n/=10;
					if(n==0)
					{
						s=sumdigit(n);
						break;
						
					}
						n++;
					s=sumdigit(n);
					r*=10;
					
					
					
				}
				//out.println(r);
				if(s==0)
				{
					out.println((long)Math.pow(10,pos)-nn);
					continue;
				}
				out.println(r*n-nn);
				 
			 }
		 }
		 
		 public int sumdigit(long n)
		 {
			 int sum=0;
			 while(n!=0)
			 {
				 sum+=n%10;
				 n/=10;
			 }
			 return sum;
		 }

		 
		 static long gcd(long a, long b) 
		    { 
		        if (a == 0) 
		            return b; 
		        return gcd(b % a, a); 
		    } 
		 
		 
		 
		 static long ncr(int n, int r, long p) 
		    { 
			 if(r>n)
				 return 0l;
		        if (r > n - r) 
		            r = n - r; 
		  
		        long C[] = new long[r + 1]; 
		  
		        C[0] = 1; 
		  
		        for (int i = 1; i <= n; i++) { 
		  
		            for (int j = Math.min(i, r); j > 0; j--) 
		                C[j] = (C[j] + C[j - 1]) % p; 
		        } 
		        return C[r]%p; 
		    } 
	    
	  public long power(long x, long y, long p) 
	    { 
	        long res = 1;      
	      // out.println(x+" "+y);
	        x = x % p;  
	       if (x == 0) return 0;    
	  
	        while (y > 0) 
	        { 
	            if((y & 1)==1) 
	                res = (res * x) % p; 
	            y = y >> 1;  
	            x = (x * x) % p;  
	        } 
	        return res; 
	    } 
	    
	    		
	    
	    
	    
	    
	    
	    static Throwable uncaught;
	 
	    BufferedReader in;
	    FastScanner sc;
	    PrintWriter out;
	 
	    @Override
	    public void run() {
	        try {
	            in = new BufferedReader(new InputStreamReader(System.in));
	            out = new PrintWriter(System.out);
	            sc = new FastScanner(in);
	            solve();
	        } catch (Throwable uncaught) {
	            Solution.uncaught = uncaught;
	        } finally {
	            out.close();
	        }
	    }
	 
	    public static void main(String[] args) throws Throwable {
	        Thread thread = new Thread(null, new Solution(), "", (1 << 26));
	        thread.start();
	        thread.join();
	        if (Solution.uncaught != null) {
	            throw Solution.uncaught;
	        }
	    }
	 
	}
	 
	class FastScanner {
	 
	    BufferedReader in;
	    StringTokenizer st;
	 
	    public FastScanner(BufferedReader in) {
	        this.in = in;
	    }
	 
	    public String nextToken() throws Exception {
	        while (st == null || !st.hasMoreTokens()) {
	            st = new StringTokenizer(in.readLine());
	        }
	        return st.nextToken();
	    }
	 
	    public int nextInt() throws Exception {
	        return Integer.parseInt(nextToken());
	    }
	    
	    public int[] readArray(int n) throws Exception {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	 
	    public long nextLong() throws Exception {
	        return Long.parseLong(nextToken());
	    }
	 
	    public double nextDouble() throws Exception {
	        return Double.parseDouble(nextToken());
	    }
	 
	}