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.*;
import java.util.*;

public class R667D {
	public static void main(String[] args) {
		JS scan = new JS();
		int t = scan.nextInt();
		while(t-->0) {
			long n = scan.nextLong(); 
			String s = Long.toString(n);
			char[] a = s.toCharArray();
			int max = scan.nextInt();
			long[] place = new long[19];
			for(int i = 1;i<19;i++) {
				place[i] = (long) Math.pow(10, (i));
			}
			if(n==(long)(Math.pow(10, 18))) {
				System.out.println(0);
				continue;
			}
			int sumss = 0;
			for(int i =0;i<s.length();i++) {
				sumss+=s.charAt(i)-'0';
			}
			if(sumss<=max) {
				System.out.println(0);
				continue;
			}
			
			for(int i = a.length;i>=0;i--) {
				int idx = a.length-i;
				long steps = 0;
				String last = s.substring(i);
				long lastt = 0L;
				if(i<a.length)
					lastt = Long.parseLong(last);
				steps = place[idx]-lastt;
				String curr = s.substring(0,i);
				while(curr.length()!=a.length)curr+="0";
				int sum = 0;
				for(int j = 0;j<curr.length();j++) {
					sum+=curr.charAt(j)-'0';
				}
				if(sum<max) {
					System.out.println(steps);
					break;
				}
			}
		}
	}
	static class JS{
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public JS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public JS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}				
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
	}

}