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:

// Problem: D. Decrease the Sum of Digits
// Contest: Codeforces - Codeforces Round #667 (Div. 3)
// URL: http://codeforces.com/problemset/problem/1409/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

import java.io.*;
import java.util.*;

public class Main {
    private static PrintWriter pw = new PrintWriter(System.out);
    private static InputReader sc = new InputReader();

    static class InputReader{
        private static BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        private static StringTokenizer tk;

        private void next()throws IOException{
            while(tk == null || !tk.hasMoreTokens())   
                tk = new StringTokenizer(r.readLine());
        }

        private int nextInt()throws IOException{
            next();
            return Integer.parseInt(tk.nextToken());
        }

        private long nextLong()throws IOException{
            next();
            return Long.parseLong(tk.nextToken());
        }
    }

    public static void main(String args[])throws IOException{
        int t = sc.nextInt();
        while(t-->0)    solve();
        pw.flush();
        pw.close();
    }
    
    private static int length(long no){
    	if(no == 0)	return 1;
    	int len = 0;
    	while(no > 0){
    		len++;
    		no /= 10;
    	}
    	return len;
    }
    
    private static int[] converter1(long no){
    	int len = length(no), res[] = new int[len], index = len - 1;
    	
    	while(index >= 0){
    		res[index--] = (int)(no%10);
    		no /= 10;
    	}
    	
    	return res;
    }
    
    private static int sum(int arr[]){
    	int sum = 0;
    	
    	for(int no: arr)	sum += no;
    	
    	return sum;
    }
    
    private static long converter2(int arr[]){
    	long ans = 0;
    	
    	for(int no: arr)
    		ans = ans * 10 + no;
    	
    	return ans;
    }

    private static void solve()throws IOException{
		long input = sc.nextLong();
		int s = sc.nextInt(), arr[] = converter1(input);
		
		if(sum(arr) <= s){
			pw.println(0);
			return;
		}
		
		for(int index = arr.length - 1; index >= 0; index--){
			int temp[] = new int[arr.length + 1];
			
			for(int ptr = 0; ptr < index; ptr++)
				temp[ptr + 1] = arr[ptr];
				
			if(temp[index] == 9)
				continue;
				
			temp[index]++;
			
			if(sum(temp) <= s){
				pw.println(+(converter2(temp) - input));
				return;
			}
		}
    }
}