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 Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	static int gcd(int a,int b)
	{
		if(a==0)
			return b;
		if(b==0)
			return a;
		if(a>b)
			return gcd(a%b,b);
		return gcd(a,b%a);
	}
	static int sum(long n)
	{
		int ans=0;
		while(n!=0)
		{
			ans=ans+(int)(n%10);
			n=n/10;
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		int cases=cin();
		while(cases!=0)
		{
			cases--;
			long[]ar=splitL();
			long n=ar[0];
			int s=(int)ar[1];
			int init=0;
			long x=n;
			while(x!=0)
			{
				init=init+(int)(x%10);
				x=x/10;
			}
			if(init<=s)
				System.out.println(0);
			else
			{
				long moves=0;
				long h=(long)1;
				long y=n;
				while(y!=0)
				{
					int d=(int)(y%10);
					if(d==0)
					{
						y=y/10;
						h=h*10;
						continue;
					}
					long c=(long)(10-d)*h;
					moves=moves+c;
					n=n+c;
					int g=sum(n);
					if(g<=s)
						break;
//					System.out.println(y+" "+d+" "+g);
					h=h*10;
					y=n/h;
				}
				System.out.println(moves);
			}
		}
	}
}