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.*;
public class temp{
	public static int get_sum(long n){
		int sum = 0;
		while(n!=0){
				sum += n%10;
				n /= 10;
			}
		return sum;
	}
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0){
			long n = sc.nextLong();
			int sum = 0;
			long temp = n;
			while(temp!=0){
				sum += temp%10;
				temp /= 10;
			}
			int s = sc.nextInt();
			long moves = 0;
			long power = 1;
			while(sum>s){
				long tmp =n%10;
				n/=10;
				power*=10;
				if(tmp==0)
					continue;
				moves += (power/10)*(10-tmp);
				n+=1;
				sum = get_sum(n);
				//System.out.println(sum);
			}
			System.out.println(moves);
		}
	}
}







































































/*public class temp{
	static class obj{
		int to;
		int weight;
		public obj(int x, int y){
			to = x;
			weight = y;
		}
	}
	static class obj2{
		int a;
		int b;
		public obj2(int x, int y){
			a = x;
			b = y;
		}
	}
	static long total = 0;
	public static int dfs(ArrayList<obj> arr[], PriorityQueue<obj2> pq, int vis[], int i){
		vis[i] = 1;
		int counter = 0;
		int flag = 0;
		for(int j =0;j<arr[i].size();j++){
			obj temp = arr[i].get(j);
			if(vis[temp.to] == 0){
				flag = 1;
				int tmp = dfs(arr, pq, vis, temp.to);
				pq.add(new obj2(temp.weight, tmp));
				counter += tmp;
				total += tmp*temp.weight;
			}
		}
		if(flag == 0)
			return 1;
		return counter;
	}
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-->0){
			total = 0;
			int n = sc.nextInt();
			ArrayList<obj> arr[] = new ArrayList[n];
			for(int i=0;i<n;i++)
				arr[i] = new ArrayList<>();
			long s = sc.nextLong();
			for(int i=0;i<n-1;i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				int z = sc.nextInt();
				arr[x-1].add(new obj(y-1, z));
				arr[y-1].add(new obj(x-1, z));
			}
			PriorityQueue<obj2> pq = new PriorityQueue<>(new Comparator<obj2>(){
				public int compare(obj2 x, obj2 y){
					long t1 = (x.a*x.b) - (x.a/2*x.b);
					long t2 = (y.a*y.b) - (y.a/2*y.b);
					return Long.compare(t2, t1);
				}
			});
			int vis[] = new int[n];
			dfs(arr, pq, vis, 0);
			//System.out.println(total);
			int counter = 0;
			while(total > s){
				counter++;
				obj2 temp = pq.poll();
				int new_wt = temp.a/2;
				pq.add(new obj2(new_wt, temp.b));
				total -= (temp.a - new_wt)*temp.b;
				//System.out.println("change weight "+temp.a);
			}
			System.out.println(counter);
		}
	}
}*/