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.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Mains1Util {

    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(final InputStream s){    br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(final FileReader r){    br = new BufferedReader(r);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException
        {
            final String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if(x.charAt(0) == '-')
            {
                neg = true;
                start++;
            }
            for(int i = start; i < x.length(); i++)
                if(x.charAt(i) == '.')
                {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                }
                else
                {
                    sb.append(x.charAt(i));
                    if(dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg?-1:1);
        }

        public boolean ready() throws IOException {return br.ready();}


    }

    public static void main(final String[] args) throws IOException {

//        final TreeSet<Double> set = new TreeSet<>();
//        for(double i=1;i<=Integer.MAX_VALUE;i=i*3) {
//            set.add(i);
//        }
        final Scanner s = new Scanner(System.in);
//        function3(s);
        final int n = s.nextInt();
        for (int i = 0; i < n; i++) {
            function2temp(s);
        }
    }

    private static void function(final Scanner s) throws IOException {
        final long n = s.nextLong();
        final long d = s.nextLong();
        if(d<=n) {
            System.out.println("YES");
            return;
        }
        if(Math.pow(n-1, 2) >= (4*(d-n))) {
            System.out.println("YES");
            return;
        }

        System.out.println("NO");


    }

    private static void function2(final Scanner s) throws IOException {
        final long a = s.nextLong();
        final long b = s.nextLong();
        long count =0;
        for(long i=1;i<=a;i++) {
            for(long j=1;j<=b;j++) {
                final long temp1 = (i+1)*j + i;
//                final int x = Long.toString(j).length();
//                final int x = (int)Math.floor(Math.log10(j)+1);
//                final int y = Long.toString(j).length();
//                final int y = (int)Math.floor(Math.log10(i)+1);
                final long temp = i + j + (i*j);
                if(temp == Long.parseLong(i + Long.toString(j)))  {
                    System.out.print( temp + " ");
                    count++;
                }
            }
        }

        System.out.println(count);

    }

    private static void function2temp(final Scanner s) throws IOException {
        final long a = s.nextLong();
        final long b = s.nextLong();
        long count = 0;
        long t = 0, temp=0;

        for(int j=1;j<=Long.toString(b).length();j++) {
            if(temp==0) {
                temp=9;

            } else {
                temp = Long.parseLong(Long.toString(temp) + 9);

            }

            if(temp<=b) {
                t++;
            } else {
                break;
            }
        }

        count = t*a;

        System.out.println(count);
    }
}