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.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class D {

	public static void main(String[] args) throws Exception {
		new D().go();
	}
	static boolean LOCAL = System.getProperty("ONLINE_JUDGE") == null;


	Scanner in;
	String INPUT = "6\r\n" +
			"2 1\r\n" +
			"1 1\r\n" +
			"500 4\r\n" +
			"217871987498122 10\r\n" +
			"100000000000000001 1\r\n" +
			"19304 11";


	void go() {
		if (LOCAL) {
			System.setIn(new ByteArrayInputStream(INPUT.getBytes()));
		}
		in = new Scanner(System.in);
		long startTime = System.currentTimeMillis();
		solve();
		if (LOCAL) {
			System.out.printf("[%dms]", System.currentTimeMillis()-startTime);
		}
		in.close();
	}


	PrintWriter out = new PrintWriter(System.out);
	StringBuffer sb = new StringBuffer();


	void solve() {
		int t = in.nextInt();
		for (int i=1; i<=t; i++) {
			solve2(i);
		}
		out.flush();

	} // end of solve


	void solve2(int caseNr) {
		long n = in.nextLong();
		long s = in.nextInt();
		String n_str = ""+n;


		//		if (caseNr != 5) return;
		//		System.out.println("n="+n);
		//		System.out.println("n="+s);
		//		System.out.println("n_str="+n_str);
		char[] b = n_str.toCharArray();

		long digsum = 0;
		for (int i = 0; i < b.length; i++) {
			digsum += b[i] - '0';
		}
		//		System.out.println("digsum="+digsum);


		if (digsum <= s) {
			out.println(0);
			return;
		}

		int ind = 0;
		int sumok = b[ind] - '0';
		while (ind+1 < n_str.length()-1 && sumok + b[ind+1]-'0' + 1 <= s) {
			ind++;
			sumok += b[ind] - '0';
		}
		sumok += 1;

		// System.out.println("sumok="+sumok);
		// System.out.println("ind="+ind);
		if (sumok > s) ind = -1;

		// here we get the ind of the chars we can 'keep'

		// get the 'base' number
		String base_number_str = "";
		for (int i = 0; i <=ind; i++) {
			base_number_str += b[i];
		}
		for (int i = ind+1; i < b.length; i++) {
			base_number_str += 0;
		}

		//		System.out.println(base_number_str);

		// then get the power at this index
		long powa = 1;
		for (int i = ind; i < n_str.length()-1; i++) {
			powa *= 10;
		}

		// System.out.println(powa);
		long target = Long.parseLong(base_number_str)+powa;


		out.println(target-n);


		// System.out.println("asdf");
		// System.out.println(1000000000000000000l-100000000000000001l);

	} // end of solve2


}







// 871987498122
// 871987498122
// char[] b = new char[] {'8','7','1','9','8','7','4','9','8','1','2','2'};
// char[] b = new char[] {'1','2','2'};
// char[] b = new char[] {'5','0','0'};

//		long power = 1;
//		long ans = 0;
//		for (int i = b.length-1; i >= 0; i--) {
//			ans = ans + (10l-(b[i]-'0')) * power;
//			power = power * 10;
//		}

// 2128012501878
// 239123612988
// 3239123612988

// System.out.println(ans);

//		long rem = 7871987498122l;
//		long tar = 10000000000000l;
//		System.out.println(tar-rem);