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 Solution{

    static class Pair<A, B> {

        A parent;
        B rank;

        Pair(A parent, B rank) {
            this.rank = rank;
            this.parent = parent;
        }
    }
    static class Node {
        int index;
        int value;
        Node(int k,int l)
        {
            index=k;
            value=l;
        }
    }
    static class Gnode{
        int v;
        int no;
        Gnode(int g,int i)
        {
            v=g;
            no=i;
        }
    }
    static int m=1000000007;
    static int dp[][];
    static int res=0;
    public static void main(String[] args) throws IOException {
        FastReader s1 = new FastReader();
        StringBuilder sb = new StringBuilder();
        int t=s1.I();
        while(t--!=0)
        {
            long n=s1.L();
            int s=s1.I();
            if(sum(n)<=s)
            {
                sb.append("0\n");
                continue;
            }
            char ar[] = Long.toString(n).toCharArray();
            char ans[] = new char[ar.length+1];
            int sum=0;
            int count=-1;
            for(int i=0;i<ar.length;i++)
            {
                int temp=ar[i]-'0';
                if(sum+temp>=s)
                {
                    break;
                }
                sum+=temp;
                count++;
            }
            StringBuilder Sb = new StringBuilder();
            if(count!=-1)
            {
                long no = Long.parseLong(new String(ar,0,count+1));
                no++;
//                System.out.println("no"+no+" "+count);
                Sb.append(no);
                for(int i=count+1;i<ar.length;i++)
                    Sb.append("0");
            }
            else
            {
                Sb.append("1");
                for(int i=0;i<ar.length;i++)
                    Sb.append("0");
            }
            Long val = Long.parseLong(Sb.toString());
//            System.out.println(val+" val");
            sb.append((val-n)+"\n");
        }
        System.out.println(sb);
    }
    static int sum(long n)
    {
        long sum=0;
        while(n>0)
        {
            sum+=(n%10);
            n=n/10;
        }
        return (int)sum;
    }
    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 I() {
            return Integer.parseInt(next());
        }

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static long gcd(long a, long b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }

    static float power(float x, int y) {
        float temp;
        if (y == 0) {
            return 1;
        }
        temp = power(x, y / 2);

        if (y % 2 == 0) {
            return temp * temp;
        } else {
            if (y > 0) {
                return x * temp * temp;
            } else {
                return (temp * temp) / x;
            }
        }
    }
    static long pow(long x, long y) {
        long res = 1;
        x = x % m;
        if (x < 0) {
            x += m;
        }
        while (y > 0) {
            if ((y & 1) == 1) {
                res = (res * x) % m;
                if (res < 0) {
                    res += m;
                }
            }
            y = y >> 1;
            x = (x * x) % m;
            if (x < 0) {
                x = x + m;
            }
        }
        res = res % m;
        if (res < 0) {
            res += m;
        }
        return res;
    }

    static void sieveOfEratosthenes(int n) {
        ArrayList<Integer> prime = new ArrayList<Integer>();
        boolean Prime[] = new boolean[n + 1];
        for (int i = 2; i < n; i++) {
            Prime[i] = true;
        }

        for (int p = 2; p * p <= n; p++) {
            if (Prime[p] == true) {
                prime.add(p);
                for (int i = p * p; i <= n; i += p) {
                    Prime[i] = false;
                }
            }
        }
    }
}