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.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	static long ans = 0;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader s = new FastReader();
		int tc = s.nextInt();
		while(tc-- > 0) {
			ans = 0;
			long n = s.nextLong();
			int sum = s.nextInt();
			while(total(n) > sum) {
				n = func(n , sum);
			}
			System.out.println(ans);
		}
	}
	
	public static long func(long n , int sum) {
		long temp = n;
		int count = 0;
		while(temp % 10 == 0) {
			temp /= 10;
			count++;
		}
		long val = temp % 10;
		val = (10 - val) * (long)Math.pow(10, count);
		ans += val;
		n += val;
		return n;
	}
	
	public static int total(long n) {
		int sum = 0;
		while(n != 0) {
			sum += (n%10);
			n /= 10;
		}
		return sum;
	}
	
	public static int lis(int arr[], int n , int Max)
    {
        int lis[] = new int[n];
        int i, j, max = 0;
 
        /* Initialize LIS values for all indexes */
        for (i = 0; i < n; i++)
            lis[i] = 1;
 
        /* Compute optimized LIS values in
           bottom up manner */
        for (i = 1; i < n; i++)
            for (j = 0; j < i; j++)
                if (lis[i] < lis[j] + 1 && Math.abs(arr[j] - arr[i]) >= Max)
                    lis[i] = lis[j] + 1;
 
        /* Pick maximum of all LIS values */
        for (i = 0; i < n; i++)
            if (max < lis[i])
                max = lis[i];
 
        return max;
    }
	
	

	public static int div(int n , int k) {
		int root = (int)Math.sqrt(n);
		root = Math.min(root , k);
		int ans = -1;
		for(int i = 2;i <= root;i++) {
			if(n % i == 0) {
				if(n/i <= k) return n/i;
				ans = i;
			}
		}
		return ans;
	}

	public static int already(char[] ch) {
		int n = ch.length;
		char[] temp = "abacaba".toCharArray();
		int count = 0;
		for(int i = 0;i <= n - 7;i++) {
			int j = i;
			for(j = i;j < i + 7;j++) {
				if(temp[j - i] != ch[j]) break;
			}
			if(j == (i + 7)) {
				count++;
			}
		}
		return count;
	}
	public static boolean check(char[] ch , int i) {
		int n = ch.length;
		char[] temp = "abacaba".toCharArray();
		for(int j = i;j < i + 7;j++) {
			if(j == n) return false;
			if(temp[j - i] == ch[j] || ch[j] == '?') continue;
			else return false;
		}
		int j = i + 7;
		if(j + 3 >= n) return true;
		if(ch[j] != 'c' || ch[j + 1] != 'a' || ch[j + 2] != 'b' || ch[j + 3] != 'a') {
			if(j + 5 >= n) return true;
			if(ch[j] != 'b' || ch[j + 1] != 'a' || ch[j + 2] != 'c' || ch[j + 3] != 'a' || ch[j + 4] != 'b' || ch[j + 5] != 'a') return true;
			else return false;
		}
		return false;

	}

	public static long fun(int n , int k) {
		int mod = (int)1e9 + 7;
		long ans = 1;
		for(int i = 1;i <= k;i++) {
			ans = (ans * n)%mod;
		}
		return ans;
	}
	public static void AlternateST() {
		FastReader s = new FastReader();
		int tc = s.nextInt();
		for(int t = 0;t < tc;t++) {
			int n = s.nextInt();
			int x = s.nextInt();
			int y = s.nextInt();
			int[] ans = new int[n];
			int min = Integer.MAX_VALUE;
			for(int start = 1;start <= 50;start++) {
				for(int diff = 1;diff <= 50;diff++) {
					boolean hasx = false;
					boolean hasy = false;
					int[] arr = fun(n , start , diff);
					for(int a : arr) {
						if(a == x) hasx = true;
						if(a == y) hasy = true;
					}
					if(hasx && hasy && arr[n - 1] < min) {
						min = arr[n - 1];
						ans = arr;
					}
				}
			}
			for(int i : ans) {
				System.out.print(i + " ");
			}
			System.out.println();

		}
	}
	public static int[] fun(int n , int start , int diff) {
		int[] ans = new int[n];
		ans[0] = start;
		for(int i = 1 ;i < n;i++) {
			ans[i] = ans[i - 1] + diff;
		}
		return ans;
	}
}
class FastReader 
{ 
	BufferedReader br; 
	StringTokenizer st; 

	public FastReader() 
	{ 
		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 nextInt() 
	{ 
		return Integer.parseInt(next()); 
	} 

	long nextLong() 
	{ 
		return Long.parseLong(next()); 
	} 

	double nextDouble() 
	{ 
		return Double.parseDouble(next()); 
	} 

	String nextLine() 
	{ 
		String str = ""; 
		try
		{ 
			str = br.readLine(); 
		} 
		catch (IOException e) 
		{ 
			e.printStackTrace(); 
		} 
		return str; 
	}
}