Try guessing the statement from this picture <http://tiny.cc/ogyoiz>.

You are given two integers A and B, calculate the number of pairs (a, b) such that 1 ≤ a ≤ A, 1 ≤ b ≤ B, and the equation a ⋅ b + a + b = conc(a, b) is true; conc(a, b) is the concatenation of a and b (for example, conc(12, 23) = 1223, conc(100, 11) = 10011). a and b should not contain leading zeroes.

Input

The first line contains t (1 ≤ t ≤ 100) — the number of test cases.

Each test case contains two integers A and B (1 ≤ A, B ≤ 10^9).

Output

Print one integer — the number of pairs (a, b) such that 1 ≤ a ≤ A, 1 ≤ b ≤ B, and the equation a ⋅ b + a + b = conc(a, b) is true.

Example

Input


3
1 11
4 2
191 31415926


Output


1
0
1337

Note

There is only one suitable pair in the first test case: a = 1, b = 9 (1 + 9 + 1 ⋅ 9 = 19).
import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        OutputStream outputStream = System.out;
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
        PROBLEM solver = new PROBLEM();
        int t=1;
        t = in.nextInt();
        for(int i=0;i<t;i++){
            solver.solve(in, out);
        }
        out.close();
    }
    static class PROBLEM
    {
        public void solve(FastReader in,PrintWriter out)
        {

            int a = in.nextInt();
            int b = in.nextInt();
            long c = 0, d = 0;

            while(d <= b){
                c++;
                d = (long)Math.pow(10,c) - 1;
            }



            long ans = a*(c-1);

            out.println(ans);



        }
    }

    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());}

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

        char nextChar(){return next().charAt(0);}

        boolean nextBoolean(){return !(nextInt()==0);}
        // boolean nextBoolean(){return Boolean.parseBoolean(next());}

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

    }

    private static int[] mergeSort(int[] array){

        if(array.length <= 1){
            return array;
        }

        int midpoint = array.length / 2;

        int[] left = new int[midpoint];
        int[] right;

        if(array.length % 2 == 0){
            right = new int[midpoint];
        }else{
            right = new int[midpoint + 1];
        }

        for (int i = 0; i < left.length; i++) {
            left[i] = array[i];
        }

        for (int i = 0; i < right.length; i++) {
            right[i] = array[i + midpoint];
        }

        int[] result = new int[array.length];

        left = mergeSort(left);
        right = mergeSort(right);

        result = merge(left, right);

        return result;
    }

    private static int[] merge(int[] left, int[] right){

        int[] result = new int[left.length + right.length];
        int leftPointer = 0, rightPointer = 0, resultPointer = 0;

        while(leftPointer < left.length || rightPointer < right.length){

            if(leftPointer < left.length && rightPointer < right.length){

                if(left[leftPointer] < right[rightPointer]){
                    result[resultPointer++] = left[leftPointer++];
                }else{
                    result[resultPointer++] = right[rightPointer++];
                }
            }else if(leftPointer < left.length){
                result[resultPointer++] = left[leftPointer++];
            }else{
                result[resultPointer++] = right[rightPointer++];
            }
        }
        return result;
    }
}
