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.*;
import java.io.*;
import java.math.BigInteger;
public class D{
public static long freq[];
public static long mod = 1000000007;
public static int dx[] = {-1,0,1,0,-1,-1,1,1,-1};//primero ady, despues esq
public static int dy[] = {0,1,0,-1,1,1,-1,-1};
public static void main(String args[]) throws IOException{
StringBuilder sb = new StringBuilder("");
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
//String tmp[] = lector.readLine().split(" ");
int cas = Integer.parseInt(lector.readLine());
for(int c = 0;c<cas;c++){
String t[] = lector.readLine().split(" ");
long s = Long.parseLong(t[1]);
freq = new long[t[0].length()];
freq[0]=(long)(t[0].charAt(0)-'0');
for(int n = 1;n<freq.length;n++){
freq[n]=freq[n-1]+(long)(t[0].charAt(n)-'0');
}
boolean entro = false;
long tal =0;
for(int n = 0;n<freq.length;n++){
if(freq[n]>=s){
if(freq[n]==s && freq[freq.length-1]-freq[n]==0)break;
//System.out.println(n+" "+freq[0]);
tal =(long)Math.pow(10,freq.length-n)-Long.parseLong(t[0].substring(n,t[0].length()));
entro = true;
break;
}
}
sb.append((entro?tal:0)+"\n");
}
System.out.print(sb);
}

}
class p implements Comparable{
public int a;
public p(int a){
this.a = a;
}
public String toString(){
return "";
}
public int compareTo(Object o){
p pp = (p)o;
return (int)Math.signum(a-pp.a);
}
}
//sergio1