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:
//WHEN IN DOUBT , USE BRUTE FORCE !!!!!!!!!
import java.lang.String;
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
//class Main    //AtCoder()
//class Solution // Codechef
public class Solution2 //Codeforces
{
    public static void main(String args[])
    {
        try {
            FastReader sc = new FastReader();
            int TT = sc.nextInt();
            for(int hehe=1 ; hehe  <= TT ; hehe++){
                long N = sc.nextLong();
                int s = sc.nextInt();
                String str = Long.valueOf(N).toString();
                if(isCheck(N,s)){
                    sopln("0");
                    continue;
                }
                else if(str.length() == 1){
                    if(s < N)
                        sopln((10-N));
                    else
                        sopln(s - N);
                }
                else{
                    long sum=0l;
                    char st[]=str.toCharArray();
                    char st1[]=new char[1+str.length()];
                    st1[0]='0';
                    for(int i=1;i<=str.length();i++){
                        st1[i]=st[i-1];
                    }
                    int cnt = 0;
                    for(int i = st1.length - 1 ; i >= 1 ; i--){
                        cnt++;
                        long mul10 = (long)Math.pow(10 , cnt);
                        long quot = N/mul10;
                        quot = quot+ 1;
                        String str22 = String.valueOf(quot);
                        for(int j = i;j<= st1.length-1;j++){
                            str22 += "0";
                        }
                        //sopln(str22);
                        long newNum = Long.valueOf(str22);
                        if(isCheck(newNum,s)){
                            sopln(newNum-N);
                            break;
                        }
                    }
                }
            }
            out.flush();
        }catch (Exception e) {
            sopln(e.toString());
        }
    }
    static boolean isCheck(long newNum , int s){
        String ss=Long.valueOf(newNum).toString();
        long ssum=0;
        for(int i=0;i<ss.length();i++){
            ssum+=ss.charAt(i)-'0';
        }
        return (ssum <= s);
    }
    public final static int d = 256;
    static int MOD = 1000000007;
    static final double PI = Math.PI;
    private static BufferedReader in = new BufferedReader (new InputStreamReader (System.in));
    private static PrintWriter out = new PrintWriter (new OutputStreamWriter (System.out));
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        char nextChar()
        {
            try {
                return (char) (br.read());
            }catch (IOException e){
                return '~';
            }
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    static void sop(Object o){System.out.print(o);}
    static double ceil(double d){
        return Math.ceil(d);
    }
    static double floor(double d){
        return Math.floor(d);
    }
    static double round(double d){
        return Math.round(d);
    }
    static void sopln(Object o){System.out.println(o);}
    static void printArray(int arr[]){
        for(int L:arr)
            sop(L+" ");
        sopln("");
    }
}