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.Scanner;

public class Main2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		//System.out.println(("" + Long.MAX_VALUE).length());
		try(Scanner reader = new Scanner(System.in))
		{
	
			int cases = reader.nextInt();
			for (int i = 0; i < cases; i++) {
				long number = reader.nextLong();
				long targetSum = reader.nextInt();
		
			
				long calcDigits = number;
				long[] digits = new long[20]; 
				long[] greedyDigits = new long[20]; 
				int index = 0;
				while(calcDigits > 0)
				{
				   digits[index] = calcDigits % 10;
				   index++;				
				   calcDigits /= 10;
				}
				boolean backtracked = false;
				if(digits[index - 1] > targetSum )
				{
					greedyDigits[index] = 1; 
					backtracked = true;
				}
				else
				{
					greedyDigits[index -1] =  digits[index -1]; 
				}
				//System.out.printf("Start %d%n",convertDigitsToLong(greedyDigits));
			
				while(index >= 0)
				{
					
					if(getSum(greedyDigits) <=  targetSum )
					{
						index--;
						if(index >= 0)
						{
							
							if(!backtracked)
							{
								greedyDigits[index] = digits[index];
							}
							else
							{
								greedyDigits[index] = 0;
							}
						}
					
						
					}
					else
					{
						backtracked = true;
						greedyDigits[index] = 0;
						int upward = index + 1;
						greedyDigits[upward]++;
						while(greedyDigits[upward] > 9 )
						{
							greedyDigits[upward] = 0;
							upward++;
							greedyDigits[upward]++;
						}
						index++;
						
					}
				}
												
				//System.out.printf("Number %d Sum of Digits Target: %d Count: %d%n",convertDigitsToLong(greedyDigits) , targetSum,convertDigitsToLong(greedyDigits) - number);
				System.out.println(convertDigitsToLong(greedyDigits) - number);
			
			}
			
			
			
			
		}
		

		
	}

     public static long getSum(long digits[]) {
		
		long sumOfDigits = 0;

		for (int i = 0; i < digits.length; i++) {
			 sumOfDigits += digits[i];
		}		
		return sumOfDigits;
	}	
		
    public static long convertDigitsToLong(long digits[]) {
		
		String sumOfDigits = "";
		for (int i = digits.length -1; i >= 0  ; i--) {
			 sumOfDigits += digits[i];
		}
		return Long.parseLong(sumOfDigits);
	}
}