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:
// Main Code at the Bottom
import java.util.*;
import java.io.*; 
public class Main{
	//Fast IO class
    static class FastReader {
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
        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; 
        } 
    }     
    static long MOD=1000000000+7;
    //debug
    static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    // Pair
    static class pair{
    	long x,y;
    	pair(long a,long b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);  
    //Global variables and functions
    //Main function(The main code starts from here)
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
    	test=sc.nextInt();
    	while(test-->0) {
    		long d=sc.nextLong();
    		String dig=d+"";
    		int sum=sc.nextInt();
    		int n=dig.length()+1;
    		char s[]=new char[n];
    		long min=Long.MAX_VALUE;
    		int curSum=0;
    		for(int i=0;i<n-1;i++) {
    			s[i+1]=dig.charAt(i);
    			curSum+=s[i+1]-'0';
    		}
    		if(curSum<=sum) {
    			out.println(0);
    			continue;
    		}
    		s[0]='0';
    		for(int i=n-1;i>=0;i--) {
    			char tmp[]=Arrays.copyOf(s, n);
    			if(tmp[i]=='9') {
    				int j=i;
    				while(j>=0 && tmp[j]=='9') tmp[j--]='0';
    				tmp[j]++;
    			}
    			else tmp[i]++;
    			String x="";
    			int total=0;
    			for(int j=0;j<=i;j++) {
    				total+=tmp[j]-'0';
    				x+=tmp[j];
    			}
    			if(total>sum) continue;
    			for(int j=i+1;j<n;j++) x+='0';
    			long val=Long.parseLong(x);
    			min=Math.min(min, val-d);
    		}
    		out.println(min);
    	}	
        out.flush();
        out.close();
    }
}