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:
//note: 0<=|int|<=2 * 10^9
//note: 0<=|long|<= 9 * 10^18
//note: 20! max w/ long
//note: 91st fibonacci # highest calculable w/long
//note: 0 <= |double| <= 1.8 * 10^308
//note: 170! max w/long;
//java machine can make 10^8 computations in a second.
import java.io.*;
import java.util.*;
import java.math.BigInteger;
    
public class CP{
    private static int MAX = Integer.MAX_VALUE;
    private static int MIN = Integer.MIN_VALUE;
    public static void main(String[] args) throws IOException{
    	FastScanner sc = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
       
        int t = sc.nextint();
        while(t-- > 0) {
        	long pow = 1;
        	int sum = 0;
        	long num = sc.nextlong();
        	long ans = num;
        	int s = sc.nextint();
        	//342341 sum
        	int count = 0;
        	while(true && count <= 20) {
        		int sumDigit = 0;
        		long temp = ans;
        		while(temp != 0) {
        			sumDigit += temp%10;
        			temp/=10;
        		}
        		if(sumDigit <= s) {
        			System.out.println(ans - num);
        			break;
        		}
        		else {
        			if((long) (ans/pow) % 10 != 0) {
        				ans += (((long) pow*10 - pow * (( ans/pow) %10)));
        			}
        		}
        		pow*=10;
        		++count;
        	}
        	
        }
        
        
        out.close(); 
    }
   
    private static class FenTree{
    	private long[] tree;
    	public FenTree(int size) {
    		tree = new long[size+1];
    	}
    	
    	public void add(int index, int add) {
    		while(index < tree.length) {
    			tree[index] += add;
    			index += (index & -index);
    		}
    	}
    	
    	public long sum(int index) {
    		long sum = 0;
    		while(index > 0) {
    			sum += tree[index];
    			index -= (index & -index);
    		}
    		
    		return sum;
    	}
    }
    
    public static boolean contains(List<Integer> arr, int key){
        int left = 0;
        int right= arr.size();
        while(left < right){
            int mid = left + (right-left)/2;
            if(arr.get(mid) == key){
                return true;
            }
            else if(arr.get(mid) < key){
                left = mid +1;
            }
            else{
                right = mid;
            }
        }
        return false;
    }
    
    private static long modInverse(long a, long b) {
        long bb = b, temp, q;
        long x0 = 0, x1 = 1;
        if(b == 1){
            return 1L;
        }
        while(a > 1){
            q = a/b;
            temp = b; b = a%b; a=temp;
            temp = x0; x0 = x1-q*x0; x1 = temp;
        }
        if(x1 < 0){
            x1 += bb;
        }
        return x1;
    }
    
    private static int gcd(int a, int b){
        if(a == 0){
            return b;
        }
        return gcd(b%a, a);
    }

    static final Random random = new Random();
    
    static void sort(int[] a) {
    	int n = a.length;
    	for(int i = 0; i< n; i++) {
    		int r = random.nextInt(n), temp=a[r];
    		a[r] = a[i]; a[i] = temp;
    	}
    	Arrays.sort(a);
    }
    
    private static PrintWriter out;
    private static BufferedReader br;
    private static StringTokenizer st;
    
    private static class FastScanner{
    	public FastScanner() {
    		br = new BufferedReader(new InputStreamReader(System.in));
    	}
    	
    	String next() {
    		while(st == null || !st.hasMoreTokens()) {
    			try {
    				st = new StringTokenizer(br.readLine());
    			}
    			catch (IOException e) {
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}
    	
    	int[] read(int n) {
    		int[] res = new int[n];
    		for(int i = 0; i < n; i++) {
    			res[i] = nextint();
    		}
    		return res;
    	}
    	
    	int nextint() {
    		return Integer.parseInt(next());
    	}
    	
    	double nextdouble() {
    		return Double.parseDouble(next());
    	}
    	
    	long nextlong() {
    		return Long.parseLong(next());
    	}
    	
    	String nextline() {
    		String str = "";
    		try {
    			str = br.readLine();
    		}
    		catch (IOException e) {
    			e.printStackTrace();
    		}
    		return str;
    	}
    	
    }
    
}