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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

import java.io.*;
	

	
public class cf {
	static InputReader obj = new InputReader(System.in);
	static long mod = (long)1e9+7;
	public static void main(String args[]) {
		main();
	}
	
	static void main() {
		int t=obj.nextInt();
		while(t-->0) {
			long n=obj.nextLong();
			long s=obj.nextLong();
			long sum=sumn(n);
			if(sum<=s) {
				System.out.println(0);
				continue;
			}
			long a=10;
			long z=n;
			while(z%10==0) {
				z/=10;
				a*=10;
			}
			z=n;
			while(sumn(z)>s) {
				long x=z%a;
				z+=(a-x);
				a*=10;
			}
			System.out.println(z-n);
			
		}
	}
	public static long sumn(long n) {
		long sum=0;
		long z=n;
		while(z!=0) {
			sum+=z%10;
			z/=10;
		}
		return sum;
	}
	
	public static long f(long a, long b, long x, long y, long k) {
		long s=a;
        a -= Math.min(a-x,k);
        k -= Math.min(s-x,k);
        if(k>0) b -= Math.min(b-y,k);
        return a*b;
	}

	
	
	public static void input(int arr[], int n) {
		for(int i=0;i<n;i++) {
	    	arr[i] = obj.nextInt();
	    }
	}
	
	public static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;
	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }
 
	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }
 
	    public int nextInt() {
	        return Integer.parseInt(next());
	    }
 
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	}

}