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.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public Main() throws FileNotFoundException {
//
//		File file = Paths.get("input.txt").toFile();
//		if (file.exists()) {
//			System.setIn(new FileInputStream(file));
//		}
//		// long t = System.currentTimeMillis();

		InputReader reader = new InputReader();

		int tt = reader.nextInt();

		for (int t = 0; t < tt; t++) {

			char[] c=reader.nextString().toCharArray();
			int n=reader.nextInt();
			
			int[] a=new int[c.length];
			int[] a2=new int[c.length];
			for(int i=0;i<c.length;i++) {
				a[i]=(int)(c[i]-'0');
				a2[i]=(int)(c[i]-'0');
			}
			
		
			int sum=0;
			
			for(int i=0;i<c.length;i++) {
				
				if(sum+a[i]<=n) {
					sum+=a[i];
					
					if(i==c.length-1) {
						System.out.println(0);
						break;
					}
					
				}else {
					int j=i;
					while(j>0) {
						if(a[j-1]<9) {
							a[j-1]++;
							sum++;
							if(sum<=n) {
								break;
							}else {
								sum-=a[j-1];
								j--;
							}
						}else {
							sum-=a[j-1];
							a[j-1]=0;
						    j--;
						}
					}
					if(j==0) {
						
						a=new int[a.length+1];
						
						a[0]=1;

						
					}else {				
						//System.out.println(j-1+":"+sum);
						for(int k=j;k<a.length;k++) {
							a[k]=0;
						}
						//System.out.println(Arrays.toString(a));

					}
					StringBuilder sb1=new StringBuilder();
					for(int ii=0;ii<a.length;ii++) {
						sb1.append(a[ii]+"");
					}
					BigInteger bi1=new BigInteger(sb1.toString());
					StringBuilder sb2=new StringBuilder();
					for(int ii=0;ii<a2.length;ii++) {
						sb2.append(a2[ii]+"");
					}
					BigInteger bi2=new BigInteger(sb2.toString());
					//2128012501878
					//2128012501878
					BigInteger diff=bi1.subtract(bi2);
					System.out.println(diff.toString());
					break;
				}
			}
		}
	}

	static class InputReader {
		private byte[] buf = new byte[16384];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main();
	}

}