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.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int Q = sc.ni();
        for (int q = 0; q < Q; q++) {
        	long N = sc.nl();
        	String num = Long.toString(N);
        	int D = num.length();
        	int S = sc.ni();
        	if (sum(N)<=S) {
        		pw.println(0);
        		continue;
        	}
        	int[] pref = new int[D+1];
        	for (int i = 1; i <= D; i++)
        		pref[i] = pref[i-1]+(num.charAt(i-1)-'0');
        	long ans = 1L;
        	for (int i = 0; i < D; i++)
        		ans *= 10L;
        	ans = ans-N;
        	
        	long p = 1;
        	for (int i = D-2; i >= 0; i--) {
        		p *= 10;
        		if (num.charAt(i)=='9')continue;
        		int sum = pref[i+1]+1;
        		if (sum <= S) {
        			long X = (N/p)*p + p;
        			ans = Math.min(ans,X-N);
        		}
        	}
        	
        	pw.println(ans);
        }
 
        pw.close();
    }
    
    public static int sum(long n) {
    	if (n==0)
    		return 0;
    	else
    		return (int)((n%10)+sum(n/10));
    }
 
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            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 ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}