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

        for(long i=1;i<=a;i++) {
            count += t;
        }

        System.out.println(count);
    }
}


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


import java.util.*;
public class YetAnotherMemeProblem {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0 ; i<n ; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(func(a,b));
        }
    }
    public static long func(long a, long b){
        int countt = 0;
        //int length = (int) (Math.log10(b) + 1);
        for(long i=9 ; i<=b ; i+=10){
            int length = (int) (Math.log10(i) + 1);
            if(i+1 == Math.pow(10,length)){
                countt++;
            }
        }
        return countt*a;
    }
    public static String conc(long a, long b){
        String aa = Long.toString(a);
        String bb = Long.toString(b);
        return aa+bb;
    }
}


import java.util.*;
public class YetAnotherMemeProblem {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0 ; i<n ; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(func(a,b));
        }
    }
    public static long func(long a, long b){
        int countt = 0;
//        for(long i=9 ; i<=b ; i+=10){
//            int length = (int) (Math.log10(i) + 1);
//            if(i+1 == Math.pow(10,length)){
//                countt++;
//            }
//        }
        if(b<=8) countt = 0;
        else if(b<=98) countt = 1;
        else if(b<=998) countt = 2;
        else if(b<=9998) countt = 3;
        else if(b<=99998) countt = 4;
        else if(b<=999998) countt = 5;
        else if(b<=9999998) countt = 6;
        else if(b<=99999998) countt = 7;
        else if(b<=999999998) countt = 8;
        else if(b==999999999) countt = 9;
        return countt*a;
    }
}


import java.util.*;
public class YetAnotherMemeProblem {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0 ; i<n ; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(func(a,b));
        }
    }
    public static long func(long a, long b){
        int countt = 0;
//        for(long i=9 ; i<=b ; i+=10){
//            int length = (int) (Math.log10(i) + 1);
//            if(i+1 == Math.pow(10,length)){
//                countt++;
//            }
//        }
        if(b<=8) countt = 0;
        else if(b<=98) countt = 1;
        else if(b<=998) countt = 2;
        else if(b<=9998) countt = 3;
        else if(b<=99998) countt = 4;
        else if(b<=999998) countt = 5;
        else if(b<=9999998) countt = 6;
        else if(b<=99999998) countt = 7;
        else if(b<=999999998) countt = 8;
        else if(b<=1000000000) countt = 9;
        return countt*a;
    }
}


import java.util.*;
public class YetAnotherMemeProblem {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0 ; i<n ; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(func(a,b));
        }
    }
    public static int func(long a, long b){
        int countt = 0;
        for(long i=1 ; i<=a ; i++){
            for(long j=1 ; j<=b ; j++){
                Long f = i + j + (i*j);
                String str = conc(i,j);
                Long ll = Long.parseLong(str);
                if(f==ll){
                    countt++;
                }
            }
        }
        return countt;
    }
    public static String conc(long a, long b){
        String aa = Long.toString(a);
        String bb = Long.toString(b);
        return aa+bb;
    }
}


import java.util.*;
public class YetAnotherMemeProblem {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i=0 ; i<n ; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            System.out.println(func(a,b));
        }
    }
    public static long func(long a, long b){
        int countt = 0;
//        for(long i=9 ; i<=b ; i+=10){
//            int length = (int) (Math.log10(i) + 1);
//            if(i+1 == Math.pow(10,length)){
//                countt++;
//            }
//        }
        if(b<8) countt = 0;
        else if(b<98) countt = 1;
        else if(b<998) countt = 2;
        else if(b<9998) countt = 3;
        else if(b<99998) countt = 4;
        else if(b<999998) countt = 5;
        else if(b<9999998) countt = 6;
        else if(b<99999998) countt = 7;
        else if(b<999999998) countt = 8;
        else if(b==999999999) countt = 9;
        return countt*a;
    }
}


import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

 public class k {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int t=s.nextInt();
		for(int ie=0;ie<t;ie++) {
			String n=s.next();
			String d=s.next();
			int flag=0;
		if(Long.valueOf(n)>=Long.valueOf(d)) {
			for(int i=0;i<n.length();i++) {
				if(n.charAt(i)!='9') {
					flag=1;
					break;
				}

			}
			long nine=0;
			if(flag==0) {
				nine=n.length();

			}else {
				nine=n.length()-1;
			}
			long ans=0;
			for(int i=1;i<=nine;i++) {
				ans= (i*Long.valueOf(d));
			}
			System.out.println(ans);

		}else {

			for(int i=0;i<d.length();i++) {
				if(d.charAt(i)!='9') {
					flag=1;
					break;
				}

			}
			long nine=0;
			if(flag==0) {
				nine=d.length();

			}else {
				nine=d.length()-1;
			}
			long ans=0;
			for(int i=1;i<=nine;i++) {
				ans=(i*Long.valueOf(n));
			}
			System.out.println(ans);

		}

		}

	}
	}


import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

 public class k {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int t=s.nextInt();
		for(int ie=0;ie<t;ie++) {
			String n=s.next();
			String d=s.next();
			int flag=0;
		if(Long.valueOf(n)>=Long.valueOf(d)) {
			for(int i=0;i<n.length();i++) {
				if(n.charAt(i)!=9) {
					flag=1;
					break;
				}

			}
			long nine=0;
			if(flag==0) {
				nine=n.length();

			}else {
				nine=n.length()-1;
			}
			long ans=0;
			for(int i=1;i<=nine;i++) {
				ans= (i*Long.valueOf(d));
			}
			System.out.println(ans);

		}else {

			for(int i=0;i<d.length();i++) {
				if(d.charAt(i)!=9) {
					flag=1;
					break;
				}

			}
			long nine=0;
			if(flag==0) {
				nine=d.length();

			}else {
				nine=d.length()-1;
			}
			long ans=0;
			for(int i=1;i<=nine;i++) {
				ans=(i*Long.valueOf(n));
			}
			System.out.println(ans);

		}

		}

	}
	}


import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

 public class k {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int t=s.nextInt();
		for(int ie=0;ie<t;ie++) {
			String d=s.next();
			String n=s.next();
			int flag=0;

			for(int i=0;i<n.length();i++) {
				if(n.charAt(i)!='9') {
					flag=1;
					break;
				}

			}
			long nine=0;
			if(flag==0) {
				nine=n.length();

			}else {
				nine=n.length()-1;
			}
			long ans=0;

			System.out.println(Long.valueOf(d)*nine);

		}
		}

	}


import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

 public class k {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);

		int t=s.nextInt();
		for(int ie=0;ie<t;ie++) {
			String d=s.next();
			String n=s.next();
			int flag=0;

			for(int i=0;i<n.length();i++) {
				if(n.charAt(i)!=9) {
					flag=1;
					break;
				}

			}
			long nine=0;
			if(flag==0) {
				nine=n.length();

			}else {
				nine=n.length()-1;
			}
			long ans=0;
			for(int i=1;i<=nine;i++) {
				ans= (i*Long.valueOf(d));
			}
			System.out.println(ans);

		}
		}

	}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int q = 0;
            int x = 9;
            while (b >= x) {
                q++;
                x = x * 10 + 9;
            }
            System.out.println(a * q);

        }
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int q = 0;
            int x = 9;
            while (b >= x) {
                q++;
                x = x * 10 + 9;
            }
            long ans = a * q;
            System.out.println(ans);

        }
    }


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            long q = 0;
            long x = 9;
            while (b >= x) {
                q++;
                x = x * 10 + 9;
            }
            long ans = (long)a * q;
            System.out.println(ans);

        }
    }
}


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for (int i = 0; i < t; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            int q = 0;
            int x = 9;
            while (b >= x) {
                q++;
                x = x * 10 + 9;
            }
            long ans = a * q;
            System.out.println(ans);

        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = in.nextInt();
            while (T-- > 0)
            {
                long A = in.nextLong();
                long B = in.nextLong();

                A = Math.min(A, B);
                B = Math.max(A, B);

                int lengthB = Long.toString(B).length();
                long number9s = lengthB - 1;
                number9s += (B == Math.pow(10, lengthB) - 1) ? 1 : 0;

                out.println(A * number9s);
            }
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = in.nextInt();
            while (T-- > 0)
            {
                long A = in.nextLong();
                long B = in.nextLong();

                A = Math.min(A, B);
                B = Math.max(A, B);

                long div = B / 9;
                long number9s = 0;
                while (div > 0)
                {
                    number9s++;
                    div = B / (int) (Math.pow(10, number9s + 1) - 1);
                }
/*
            int lengthB = Long.toString(B).length();
            long number9s = lengthB - 1;
            number9s += (B == Math.pow(10,lengthB) - 1) ? 1 : 0;
*/
                out.println(A * number9s);
            }
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            int T = in.nextInt();
            while (T-- > 0)
            {
                long A = in.nextLong();
                long B = in.nextLong();

                int lengthB = Long.toString(B).length();
                long number9s = lengthB - 1;
                number9s += (B == Math.pow(10, lengthB) - 1) ? 1 : 0;
                out.println(A * number9s);
            }
        }

    }
}


import java.util.*;
import java.io.*;
public class Fff {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

  BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
 BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
 int q=Integer.parseInt(bf.readLine());
 StringBuffer out=new StringBuffer();
 while(q-->0){

     String in1[]=bf.readLine().split(" ");
     long l=Long.parseLong(in1[0]);
     int ll=Integer.parseInt(in1[1]);
 String stmax=ll+"";
 int cou=stmax.length()-1;
  StringBuffer out1=new StringBuffer();
 for(int i=0;i<stmax.length();i++){out1.append(9);}
 if(stmax.equals(out1.toString())){cou++;}

     bw.append(cou* l+"\n");
 }

        bw.close();
    }

}


import java.util.*;
import java.io.*;
import java.math.*;
public class Fff {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

 BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
 int q=Integer.parseInt(bf.readLine());
 StringBuffer out=new StringBuffer();
 while(q-->0){

     String in1[]=bf.readLine().split(" ");
     int l=Integer.parseInt(in1[0]);
     int ll=Integer.parseInt(in1[1]);
 String stmax=(int)Math.max(ll, l)+"";
 int cou=stmax.length()-1;
  StringBuffer out1=new StringBuffer();
 for(int i=0;i<stmax.length();i++){out1.append(9);}
 if(stmax.equals(out1.toString())){cou++;}

     out.append(cou*Math.min(l, ll)+"\n");
 }
        System.out.print(out);
   }

}


import java.util.*;
import java.io.*;
import java.math.*;
public class Fff {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

 BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
 int q=Integer.parseInt(bf.readLine());
 StringBuffer out=new StringBuffer();
 while(q-->0){

     String in1[]=bf.readLine().split(" ");
     long l=Long.parseLong(in1[0]);
     int ll=Integer.parseInt(in1[1]);
 String stmax=ll+"";
 int cou=stmax.length()-1;
  StringBuffer out1=new StringBuffer();
 for(int i=0;i<stmax.length();i++){out1.append(9);}
 if(stmax.equals(out1.toString())){cou++;}

     out.append(cou* l+"\n");
 }
        System.out.print(out);
   }

}


import java.util.*;
import java.io.*;
import java.math.*;
public class Fff {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

 BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
 int q=Integer.parseInt(bf.readLine());
 StringBuffer out=new StringBuffer();
 while(q-->0){

     String in1[]=bf.readLine().split(" ");
     int l=Integer.parseInt(in1[0]);
     int ll=Integer.parseInt(in1[1]);
 String stmax=ll+"";
 int cou=stmax.length()-1;
  StringBuffer out1=new StringBuffer();
 for(int i=0;i<stmax.length();i++){out1.append(9);}
 if(stmax.equals(out1.toString())){cou++;}

     out.append(cou* l+"\n");
 }
        System.out.print(out);
   }

}


import java.util.*;
import java.io.*;
import java.math.*;
public class Fff {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

 BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
 int q=Integer.parseInt(bf.readLine());
 StringBuffer out=new StringBuffer();
 while(q-->0){

     String in1[]=bf.readLine().split(" ");
     int l=Integer.parseInt(in1[0]);
     int ll=Integer.parseInt(in1[1]);
 String stmax=(int)Math.max(ll, l)+"";
 int cou=stmax.length()-1;
 if(stmax.equals(Math.pow(9, stmax.length()))){cou++;}
      out.append(cou*Math.min(l, ll)+"\n");
 }
        System.out.print(out);
   }

}


import java.util.*;

public class b {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int T = in.nextInt();
    for(int t=0; t<T; t++) {
      long A = in.nextInt();
      long B = in.nextInt();

      // if(A > B) {
      //   A ^= B;
      //   B ^= A;
      //   A ^= B;
      // }

      // Oh my meme
      // SUCH a meme
      // Thank you brute force
      int numNinesInBig = 0;
      if(B == 9) numNinesInBig++;
      while(B >= 10) {
        numNinesInBig++;
        B /= 10;
      }

      System.out.println(A*numNinesInBig);

    }

  }
}
/*

3
1 11
4 2
191 31415926

1
0
1337

3
1 11
1 10
1 9

1
1
1

3
1 11
4 2
1910000000 1314159260

3
1 11
4 2
31415926 191

1
1 900

*/


import java.util.*;

public class b {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int T = in.nextInt();
    for(int t=0; t<T; t++) {
      long A = in.nextInt();
      long B = in.nextInt();

      if(A > B) {
        A ^= B;
        B ^= A;
        A ^= B;
      }

      // Oh my meme
      // SUCH a meme
      // Thank you brute force
      int numNinesInBig = 0;
      while(B >= 10) {
        numNinesInBig++;
        B /= 10;
      }
      if(B == 9) numNinesInBig++;

      System.out.println(A*numNinesInBig);

    }

  }
}
/*

3
1 11
4 2
191 31415926

1
0
1337

3
1 11
1 10
1 9

1
1
1

3
1 11
4 2
1910000000 1314159260

*/


import java.util.*;

public class b {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int T = in.nextInt();
    for(int t=0; t<T; t++) {
      long A = in.nextInt();
      long B = in.nextInt();

      // if(A > B) {
      //   A ^= B;
      //   B ^= A;
      //   A ^= B;
      // }

      // Oh my meme
      // SUCH a meme
      // Thank you brute force
      int numNinesInBig = 0;
      while(B >= 10) {
        numNinesInBig++;
        B /= 10;
      }
      if(B == 9) numNinesInBig++;

      System.out.println(A*numNinesInBig);

    }

  }
}
/*

3
1 11
4 2
191 31415926

1
0
1337

3
1 11
1 10
1 9

1
1
1

3
1 11
4 2
1910000000 1314159260

3
1 11
4 2
31415926 191

*/


import java.util.*;

public class b {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int T = in.nextInt();
    for(int t=0; t<T; t++) {
      long A = in.nextInt();
      long B = in.nextInt();

      // if(A > B) {
      //   A ^= B;
      //   B ^= A;
      //   A ^= B;
      // }

      // Oh my meme
      // SUCH a meme
      // Thank you brute force
      int numNinesInBig = 0;
      B++;
      // if(B == 9) numNinesInBig++;
      while(B >= 10) {
        numNinesInBig++;
        B /= 10;
      }

      System.out.println(A*numNinesInBig);

    }

  }
}
/*

3
1 11
4 2
191 31415926

1
0
1337

3
1 11
1 10
1 9

1
1
1

3
1 11
4 2
1910000000 1314159260

3
1 11
4 2
31415926 191

2
1 900
1 999

2
3

*/


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class conc
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String[] s=br.readLine().split(" ");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			long temp=9;
			long cnt=0;
			while(b>=temp)
			{
				temp*=10;
				temp+=9;
				cnt+=a;
			}
			System.out.println(cnt);
		}

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class conc
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String[] s=br.readLine().split(" ");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			int temp=9;
			int cnt=0;
			while(b>=temp)
			{
				temp=temp*10+9;
				cnt++;
			}
			System.out.println(cnt*a);
		}

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class conc
{
	public static void main(String args[]) throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String[] s=br.readLine().split(" ");
			int a=Integer.parseInt(s[0]);
			int b=Integer.parseInt(s[1]);
			int temp=9;
			int cnt=0;
			while(b>=temp)
			{
				temp*=10;
				temp+=9;
				cnt+=a;
			}
			System.out.println(cnt);
		}

	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int A = sc.nextInt();
		    int B = sc.nextInt();
		    int count = 0;
		    while(B >= 9){
		        B /= 10;
		        count++;
		    }
		    out.println(count * A);
		}
		out.flush();
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int A = sc.nextInt();
		    int B = sc.nextInt();
		    int count = 0;
		    while(B >= 10){
		        B /= 10;
		        count++;
		    }
		    out.println(count * A);
		}
		out.flush();
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int A = sc.nextInt();
		    int B = sc.nextInt();
		    int count = 0;
		    long num = 9;
		    while(num <= B){
		        count++;
		        num = num * 10 + 9;
		    }
		    out.println(count * A);
		}
		out.flush();
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int A = sc.nextInt();
		    int B = sc.nextInt();
		    int count = 0;
		    long num = 9;
		    while(num <= B){
		        count++;
		        num = num * 10 + 9;
		    }
		    out.println((long)count * A);
		}
		out.flush();
	}
}


import java.util.*;

import java.io.*;

public class B {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String inp[] = br.readLine().split(" ");
			int n = Integer.parseInt(inp[0]);
			int m = Integer.parseInt(inp[1]);
			int max = Math.max(n, m);
			int min = Math.min(n,m);
			int dif = max-min;
			long ans=0l;
			long x=10;
			while(x<=(int)1e9)
			{
				if(max>=x-1)ans+=min;
				else
					break;
				x*=10;
			}
			pw.println(ans);
		}
		pw.flush();
	}

}


import java.util.*;

import java.io.*;

public class B {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String inp[] = br.readLine().split(" ");
			int n = Integer.parseInt(inp[0]);
			int m = Integer.parseInt(inp[1]);
			long ans=0l;
			long x=10;
			while(x<=(int)1e9)
			{
				if(m>=x-1)ans+=n;
				else
					break;
				x*=10;
			}
			pw.println(ans);
		}
		pw.flush();
	}

}


import java.util.*;

import java.io.*;

public class B {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String inp[] = br.readLine().split(" ");
			int n = Integer.parseInt(inp[0]);
			int m = Integer.parseInt(inp[1]);
			int max = Math.max(n, m);
			int min = Math.min(n,m);
			long ans=0l;
			if(max>=9)
				ans+=min;
			if(max>=99)ans+=min;
			if(max>=999)ans+=min;
			if(max>=9999)ans+=min;
			if(max>=99999)ans+=min;
			if(max>=999999)ans+=min;
			if(max>=9999999)ans+=min;
			if(max>=99999999)ans+=min;
			pw.println(ans);
		}
		pw.flush();
	}

}


import java.util.*;

import java.io.*;

public class B {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			String inp[] = br.readLine().split(" ");
			int n = Integer.parseInt(inp[0]);
			int m = Integer.parseInt(inp[1]);
			int max = Math.max(n, m);
			int min = Math.min(n,m);
			long ans=0l;
			if(max>=10-1)
				ans+=min;
			if(max>=100-1)ans+=min;
			if(max>=1000-1)ans+=min;
			if(max>=10000-1)ans+=min;
			if(max>=100000-1)ans+=min;
			if(max>=1000000-1)ans+=min;
			if(max>=10000000-1)ans+=min;
			if(max>=100000000-1)ans+=min;
			if(max>=1000000000-1)ans+=min;
			pw.println(ans);
		}
		pw.flush();
	}

}


import java.util.*;
public class Problem1288b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a*(Integer.toString(b).length()-1));
        }
    }
}


import java.util.*;
public class Problem1288b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            long a = sc.nextInt();
            long b = sc.nextInt();
            boolean choice = true;
            for(int j = 0; j < Long.toString(b).length(); j++) {
                if(Long.toString(b).charAt(j) == '9') {
                }
                else {
                    choice = false;
                    break;
                }
            }
            if(choice == true) {
                System.out.println(a*Long.toString(b).length());
            }
            else {
                System.out.println(a * (Long.toString(b).length() - 1));
            }
        }
    }
}


import java.util.*;
public class Problem1288b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i < n; i++) {
            long a = sc.nextInt();
            long b = sc.nextInt();
            System.out.println(a*(Long.toString(b).length()-1));
        }
    }
}


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         for(int qw=0; qw < T; qw++)
         {
            st = new StringTokenizer(infile.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            if(A > B)
            {
               System.out.println(0);
               continue;
            }
            int cnt = 0;
            String lol = "9";
            while(Long.parseLong(lol) <= B)
            {
               cnt++;
               lol += 9;
            }
            System.out.println((long)A*cnt);
         }
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         for(int qw=0; qw < T; qw++)
         {
            st = new StringTokenizer(infile.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            if(A > B)
            {
               System.out.println(0);
               continue;
            }
            B++;
            int dig = (B+"").length()-1;
            System.out.println(dig*A);
         }
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         for(int qw=0; qw < T; qw++)
         {
            st = new StringTokenizer(infile.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            if(A > B)
            {
               System.out.println(0);
               continue;
            }
            int cnt = 0;
            String lol = "9";
            while(Long.parseLong(lol) <= B)
            {
               cnt++;
               lol += 9;
            }
            System.out.println(A*cnt);
         }
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         for(int qw=0; qw < T; qw++)
         {
            st = new StringTokenizer(infile.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            if(A > B)
            {
               System.out.println(0);
               continue;
            }
            int cnt = 0;
            String lol = "9";
            while(Integer.parseInt(lol) <= B)
            {
               cnt++;
               lol += 9;
            }
            System.out.println(A*cnt);
         }
      }
   }


/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
*/
import java.util.*;
import java.io.*;

   public class B
   {
      public static void main(String omkar[]) throws Exception
      {
         //BufferedReader infile = new BufferedReader(new FileReader("cowdate.in"));
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int T = Integer.parseInt(st.nextToken());
         for(int qw=0; qw < T; qw++)
         {
            st = new StringTokenizer(infile.readLine());
            int A = Integer.parseInt(st.nextToken());
            int B = Integer.parseInt(st.nextToken());
            int cnt = 0;
            String lol = "9";
            while(Long.parseLong(lol) <= B)
            {
               cnt++;
               lol += 9;
            }
            System.out.println((long)A*cnt);
         }
      }
   }


import java.util.*;
public class Yet {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-- > 0) {
			int a = scan.nextInt(), b = scan.nextInt();
			int h = (int)Math.log10(b);
			if(Math.pow(10, h + 1) - 1 == b)
				h++;
			System.out.println((long)h * a);
		}
		scan.close();

	}

}


import java.util.*;
public class Yet {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-- > 0) {
			int a = scan.nextInt(), b = scan.nextInt();
			int h = (int)Math.log10(b);
			if(Math.pow(10, h + 1) > b)
				h++;
			System.out.println(h * a);
		}
		scan.close();

	}

}


import java.util.*;
public class Yet {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-- > 0) {
			int a = scan.nextInt(), b = scan.nextInt();
			int h = (int)Math.log10(b);
			if(Math.pow(10, h + 1) - 1 == b)
				h++;
			System.out.println(h * a);
		}
		scan.close();

	}

}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author mhamed Abdelsalam
 */
public class Force {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
       long count=0;
        long A= input.nextLong();
        String B = input.next();
        long r;
        long Len = B.length();
        long BB = Long.valueOf(String.valueOf(B));
        long lenPlus=BB+1;
         String lenPlusAsString = String.valueOf(lenPlus);
         long len2=  lenPlusAsString.length();
        if (Len==len2) {
          r= Len-1;
        }else
        {
        r=Len;
        }

        long test=A*r;
        System.out.println(test);


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author mhamed Abdelsalam
 */
public class Force {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
       long t= input.nextLong();

        for ( t = 0; t < 100000000; t++) {

        long A= input.nextLong();
        String B = input.next();
        long r;
        long Len = B.length();
        long BB = Long.valueOf(String.valueOf(B));
        long lenPlus=BB+1;
        String lenPlusAsString = String.valueOf(lenPlus);
        long len2=  lenPlusAsString.length();
        if (Len==len2) {
          r= Len-1;
        }else
        {
        r=Len;
        }

        long test=A*r;
        System.out.println(test);
        }
    }}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author mhamed Abdelsalam
 */
public class Force {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
       long t= input.nextLong();
       long A=0;
       String B=null;
        for ( long i = 0; i < t; i++) {
         A= input.nextLong();
         B = input.next();

        long r;
        long Len = B.length();
        long BB = Long.valueOf(String.valueOf(B));
        long lenPlus=BB+1;
        String lenPlusAsString = String.valueOf(lenPlus);
        long len2=  lenPlusAsString.length();
        if (Len==len2) {
          r= Len-1;
        }else
        {
        r=Len;
        }

        long test=A*r;
        System.out.println(test);
        }
    }}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author mhamed Abdelsalam
 */
public class Force {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
       int count=0;
        int A= input.nextInt();
        int B = input.nextInt();

        for (int a = 1; a <= A; a++) {
            for (int b = 1; b <=B; b++) {

       int c = Integer.valueOf(String.valueOf(a) + String.valueOf(b));

        if (a*b+a+b==c) {

            count++;
        }

            }

        }
           System.out.println(count);

             }

}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author mhamed Abdelsalam
 */
public class Force {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
       long count=0;
        long A= input.nextLong();
        long B = input.nextLong();

        for (long a = 1; a <= A; a++) {
            for (long b = 1; b <=B; b++) {

       long c = Long.valueOf(String.valueOf(a) + String.valueOf(b));

        if (a*b+a+b==c) {

            count++;
        }

            }

        }
           System.out.println(count);

             }

}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;

/**
 *
 * @author mhamed Abdelsalam
 */
public class Force {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);
       long count=0;
        long A= input.nextLong();
        String B = input.next();
        long r;
        long Len = B.length();
        long BB = Long.valueOf(String.valueOf(B));
        long lenPlus=BB+1;
         String lenPlusAsString = String.valueOf(lenPlus);
         long len2=  lenPlusAsString.length();
        if (Len==len2) {
          r= Len-1;
        }else
        {
        r=Len;
        }

        long test=A*r;
        System.out.println(test);
    }}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Vector;

import javax.print.attribute.standard.PrinterMessageFromOperator;

public class Main
{
    public static void main(String[] args) throws IOException
    {
    	StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		while (in.nextToken() != StreamTokenizer.TT_EOF)
		{
	        int num = (int)in.nval;
	        int num1;
	        int num2;
	        for(int i = 0; i < num; i++)
	        {
	        	in.nextToken();
	        	num1 = (int)in.nval;
	        	in.nextToken();
	        	num2 = (int)in.nval;
	        	int length = 0;
	        	for(int tempNum = num2, tempNum2 = 0; ;)
	        	{
	        		tempNum /= 10;
	        		length++;
	        		tempNum2 *= 10;
	        		tempNum2 += 9;
	        		if(tempNum == 0)
	        		{
	        			if(num2 == tempNum2)
	        			{
	        				out.println((long)num1 * length);
	        			}
	        			else
	        			{
	        				out.println((long)num1 * (length - 1));
	        			}
	        			out.flush();
	        			break;
	        		}
	        	}
	        }
		}
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Vector;

import javax.print.attribute.standard.PrinterMessageFromOperator;

public class Main
{
    public static void main(String[] args) throws IOException
    {
    	StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		while (in.nextToken() != StreamTokenizer.TT_EOF)
		{
	        int num = (int)in.nval;
	        int num1;
	        int num2;
	        for(int i = 0; i < num; i++)
	        {
	        	in.nextToken();
	        	num1 = (int)in.nval;
	        	in.nextToken();
	        	num2 = (int)in.nval;
	        	int length = 0;
	        	for(int tempNum = num2, tempNum2 = 0; ;)
	        	{
	        		tempNum /= 10;
	        		length++;
	        		tempNum2 *= 10;
	        		tempNum2 += 9;
	        		if(tempNum == 0)
	        		{
	        			if(num2 == tempNum)
	        			{
	        				out.println(num1 * length);
	        			}
	        			else
	        			{
	        				out.println(num1 * (length - 1));
	        			}
	        			out.flush();
	        			break;
	        		}
	        	}
	        }
		}
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Vector;

import javax.print.attribute.standard.PrinterMessageFromOperator;

public class Main
{
    public static void main(String[] args) throws IOException
    {
    	StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		while (in.nextToken() != StreamTokenizer.TT_EOF)
		{
	        int num = (int)in.nval;
	        int num1;
	        int num2;
	        for(int i = 0; i < num; i++)
	        {
	        	in.nextToken();
	        	num1 = (int)in.nval;
	        	in.nextToken();
	        	num2 = (int)in.nval;
	        	int length = 0;
	        	for(int tempNum = num2, tempNum2 = 0; ;)
	        	{
	        		tempNum /= 10;
	        		length++;
	        		tempNum2 *= 10;
	        		tempNum2 += 9;
	        		if(tempNum == 0)
	        		{
	        			if(num2 == tempNum)
	        			{
	        				out.println((long)num1 * length);
	        			}
	        			else
	        			{
	        				out.println((long)num1 * (length - 1));
	        			}
	        			out.flush();
	        			break;
	        		}
	        	}
	        }
		}
    }
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	static  ArrayList<Integer>adj[];
	static PrintWriter out=new PrintWriter(System.out);
	 public static int mod = 1000000007;

	static Boolean notmemo[][][];
	static int k;
	static long a[];
	static long b[];
	static int m;
	static char c[];
	static int trace[];
	public static void main(String[] args) throws Exception {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();
	label:while(t-->0) {
	int a=sc.nextInt();
	int b=sc.nextInt();
	long start=9;
	long ans=0;
	while(start<=b) {
		ans+=a;
		start*=10;
		start+=9;
	}
	out.println(ans);

	}

	out.flush();

	}
	static int teams=0;
static long mini[];
static char x[]= {'h','a','r','d'};
static long s[];
static ArrayList<Integer> l1=new ArrayList<>();
static long count=0;

static long dp(int i,int j) {

	if(i>=n) {
	return 0;
}
	if(j==x.length) {
		return INF;
	}

if(memo[i][j]!=-1) {
	return memo[i][j];
}
long ans=INF;
if(c[i]==x[j]) {
ans=Math.min(ans, dp(i+1, j)+b[i]);
ans=Math.min(ans, dp(i+1,j+1));
}
else {
	ans=Math.min(ans, dp(i+1,j));
}

return memo[i][j]=ans;

}

private static int bs(int i) {
	int high=n-1;
	int low=i;
	int ans=-1;
	int count=1;
	while(high>=low) {
	int	mid=(high+low)>>1;
	if(a[mid]-a[i]<=5) {
		ans=mid;
		low=mid+1;
		count=mid-i+1;
	}
	else {
		high=mid-1;

	}
	}
	return count;

}

/**private static void trace(int i, int time) {
if(i==n)
	return;

long ans=dp(i,time);
if(time+a[i].t<a[i].burn&&(ans==dp(i+1,time+a[i].t)+a[i].cost)) {

	trace(i+1, time+a[i].t);

	l1.add(a[i].idx);
    return;
}
    trace(i+1,time);

}**/

	static class incpair implements Comparable<incpair>
{
	int a; long b;
	int idx;
	incpair(int a, long dirg,int i) {this.a = a;	b = dirg; idx=i; }

	public int compareTo(incpair e){ return (int) (b - e.b);	}
}
	static class decpair implements Comparable<decpair>
{
	int a; long b;int idx;

	decpair(int a, long dirg,int i) {this.a = a;	b = dirg; idx=i;}

	public int compareTo(decpair e){ return (int) (e.b- b);	}
}

	static long allpowers[];
	static class Quad implements Comparable<Quad>{
		int u;
		int v;
		char state;
		int turns;
		public Quad(int i, int j, char c, int k) {
		u=i;
		v=j;
		state=c;
		turns=k;
		}
		public int compareTo(Quad e){ return (int) (turns - e.turns);	}

	}
	static long dirg[][];
	static Edge[] driver;

	static int n;
		static class Edge implements Comparable<Edge>
	{
		int node; long cost;

		Edge(int a, long dirg) { node = a;	cost = dirg; }

		public int compareTo(Edge e){ return (int) (cost - e.cost);	}
	}

	  static long manhatandistance(long x,long x2,long y,long y2) {
		  return  Math.abs(x-x2)+Math.abs(y-y2);
	  }
	  static long fib[];
	  static long fib(int n) {
		  if(n==1||n==0) {
			  return 1;
		  }
		  if(fib[n]!=-1) {
			  return fib[n];
		  }
		  else
			  return  fib[n]=  ((fib(n-2)%mod+fib(n-1)%mod)%mod);
	  }
	  static class Pair implements Comparable<Pair>{
		  long val;
		  int idx;
		  Pair(int a, long b){
			  idx=a;
			  val=b;
		  }
		public int compareTo(Pair p) {

			return (int) (this.val-p.val);
		}

	}
	static long[][] comb;
	static long nCr1(int n , int k)
	{
		if(n < k)
			return 0;
		if(k == 0 || k == n)
			return 1;
		if(comb[n][k] != -1)
			return comb[n][k];
		if(n - k < k)
			return comb[n][k] = nCr1(n, n - k);
		return comb[n][k] = (nCr1(n - 1, k - 1) + nCr1(n - 1, k))%mod;
	}

static  class Triple implements Comparable<Triple>{

int t;
int burn;
		int cost;
		int idx;
		public Triple(int a,int b,int l,int i) {
			t=a;
			burn=b;
			cost=l;
			idx=i;
		}
		@Override
		public int compareTo(Triple o) {
			return Long.compare( burn,o.burn);
		}

	}

	static TreeSet<Long> primeFactors(long N)		// O(sqrt(N) / ln sqrt(N))
	{
		TreeSet<Long> factors = new TreeSet<Long>();		//take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while(p * p <= N)
		{
			while(N % p == 0) { factors.add((long) p); N /= p; }
			if(primes.size()>idx+1)
			p = primes.get(++idx);
			else
				break;
		}

		if(N != 1)						// last prime factor may be > sqrt(N)
			factors.add(N);				// for integers whose largest prime factor has a power of 1
		return factors;
	}

	static boolean visited[];
	/**static int bfs(int s)
	{
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(s);
		int count=0;
		int maxcost=0;
		int dist[]=new int[n];
		dist[s]=0;
		while(!q.isEmpty())
		{

			int u = q.remove();
			if(dist[u]==k) {
				break;
			}
			for(Pair v: adj[u])
			{
				maxcost=Math.max(maxcost, v.cost);

			if(!visited[v.v])	{

				visited[v.v]=true;
				q.add(v.v);
				dist[v.v]=dist[u]+1;
				maxcost=Math.max(maxcost, v.cost);
			}
			}

		}
		return maxcost;
	}**/
	public static boolean FindAllElements(int n, int k) {
	 int sum = k;
     int[] A = new int[k];
      Arrays.fill(A, 0, k, 1);

      for (int i = k - 1; i >= 0; --i) {

           while (sum + A[i] <= n) {

              sum += A[i];
              A[i] *= 2;
          }
      }
      if(sum==n) {
      	return true;
      }
      else
    	return false;
	}

	static long[][] memo;

	static boolean vis2[][];

	static class SegmentTree {		// 1-based DS, OOP

		int N; 			//the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in)
		{
			array = in; N = in.length - 1;
			sTree = new int[N<<1];		//no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N<<1];
			build(1,1,N);
		}

		void build(int node, int b, int e)	// O(n)
		{
			if(b == e)
				sTree[node] = array[b];
			else
			{
				int mid = b + e >> 1;
				build(node<<1,b,mid);
				build(node<<1|1,mid+1,e);
				sTree[node] = sTree[node<<1]+sTree[node<<1|1];
			}
		}

		void update_point(int index, int val)			// O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while(index>1)
			{
				index >>= 1;
				sTree[index] = sTree[index<<1] + sTree[index<<1|1];
			}
		}

		void update_range(int i, int j, int val)		// O(log n)
		{
			update_range(1,1,N,i,j,val);
		}

		void update_range(int node, int b, int e, int i, int j, int val)
		{
			if(i > e || j < b)
				return;
			if(b >= i && e <= j)
			{
				sTree[node] += (e-b+1)*val;
				lazy[node] += val;
			}
			else
			{
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node<<1,b,mid,i,j,val);
				update_range(node<<1|1,mid+1,e,i,j,val);
				sTree[node] = sTree[node<<1] + sTree[node<<1|1];
			}

		}
		void propagate(int node, int b, int mid, int e)
		{
			lazy[node<<1] += lazy[node];
			lazy[node<<1|1] += lazy[node];
			sTree[node<<1] += (mid-b+1)*lazy[node];
			sTree[node<<1|1] += (e-mid)*lazy[node];
			lazy[node] = 0;
		}

		int query(int i, int j)
		{
			return query(1,1,N,i,j);
		}

		int query(int node, int b, int e, int i, int j)	// O(log n)
		{
			if(i>e || j <b)
				return 0;
			if(b>= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			propagate(node, b, mid, e);
			int q1 = query(node<<1,b,mid,i,j);
			int q2 = query(node<<1|1,mid+1,e,i,j);
			return q1 + q2;

		}

	}
	static boolean f2=false;
	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r)	//C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for(int i = 0; i < p; ++i) {
			for(int j = 0; j < r; ++j) {
				for(int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j]+(a2[i][k]%mod * b[k][j]%mod))%mod;
		 C[i][j]%=mod;
				}

			}
		}
		return C;
	}

	static ArrayList<Pair> a1[];
	static int memo1[];

	static boolean vis[];
	static TreeSet<Integer> set=new TreeSet<Integer>();

	static long modPow(long ways, long count, long mod)	// O(log e)
	{
		ways %= mod;
		long res = 1;
		while(count > 0)
		{
			if((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res%mod;
	}

	static long gcd(long ans,long b) {
		if(b==0) {
			return ans;
		}
		return gcd(b,ans%b);
	}
	static int[] isComposite;
	static int[] valid;

	static ArrayList<Integer> primes;
	static ArrayList<Integer> l;
	static void sieve(int N)	// O(N log log N)
	{
		isComposite = new int[N+1];
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();
		l=new ArrayList<>();
		valid=new int[N+1];
		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				l.add(i);
				valid[i]=1;

				for (int j = i*2; j <=N; j +=i) {	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;

					}
			}

		for(int i=0 ; i<primes.size() ; i++) {
			for(int j:primes) {
				if(primes.get(i)*j>N) {
					break;
				}
				valid[primes.get(i)*j]=1;
			}
		}
	}

	public static long[] schuffle(long[] a2) {
		for (int i = 0; i < a2.length; i++) {
			int x=(int)(Math.random()*a2.length);
		long temp=a2[x];
		a2[x]=a2[i];
		a2[i]=temp;
		}
		return a2;
	}
		static int V;
	static long INF=(long) 1E16;

		static class Edge2
		{
			int node;
		long cost;
			long next;
			Edge2(int a, int c,Long long1) { node = a;	cost = long1; next=c;}

		}
static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

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

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

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

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

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

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	static  ArrayList<Integer>adj[];
	static PrintWriter out=new PrintWriter(System.out);
	 public static int mod = 1000000007;

	static Boolean notmemo[][][];
	static int k;
	static long a[];
	static long b[];
	static int m;
	static char c[];
	static int trace[];
	public static void main(String[] args) throws Exception {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();
	label:while(t-->0) {
	int a=sc.nextInt();
	int b=sc.nextInt();
	int start=9;
	long ans=0;
	while(start<b) {
		ans+=a;
		start*=10;
	}
	out.println(ans);

	}

	out.flush();

	}
	static int teams=0;
static long mini[];
static char x[]= {'h','a','r','d'};
static long s[];
static ArrayList<Integer> l1=new ArrayList<>();
static long count=0;

static long dp(int i,int j) {

	if(i>=n) {
	return 0;
}
	if(j==x.length) {
		return INF;
	}

if(memo[i][j]!=-1) {
	return memo[i][j];
}
long ans=INF;
if(c[i]==x[j]) {
ans=Math.min(ans, dp(i+1, j)+b[i]);
ans=Math.min(ans, dp(i+1,j+1));
}
else {
	ans=Math.min(ans, dp(i+1,j));
}

return memo[i][j]=ans;

}

private static int bs(int i) {
	int high=n-1;
	int low=i;
	int ans=-1;
	int count=1;
	while(high>=low) {
	int	mid=(high+low)>>1;
	if(a[mid]-a[i]<=5) {
		ans=mid;
		low=mid+1;
		count=mid-i+1;
	}
	else {
		high=mid-1;

	}
	}
	return count;

}

/**private static void trace(int i, int time) {
if(i==n)
	return;

long ans=dp(i,time);
if(time+a[i].t<a[i].burn&&(ans==dp(i+1,time+a[i].t)+a[i].cost)) {

	trace(i+1, time+a[i].t);

	l1.add(a[i].idx);
    return;
}
    trace(i+1,time);

}**/

	static class incpair implements Comparable<incpair>
{
	int a; long b;
	int idx;
	incpair(int a, long dirg,int i) {this.a = a;	b = dirg; idx=i; }

	public int compareTo(incpair e){ return (int) (b - e.b);	}
}
	static class decpair implements Comparable<decpair>
{
	int a; long b;int idx;

	decpair(int a, long dirg,int i) {this.a = a;	b = dirg; idx=i;}

	public int compareTo(decpair e){ return (int) (e.b- b);	}
}

	static long allpowers[];
	static class Quad implements Comparable<Quad>{
		int u;
		int v;
		char state;
		int turns;
		public Quad(int i, int j, char c, int k) {
		u=i;
		v=j;
		state=c;
		turns=k;
		}
		public int compareTo(Quad e){ return (int) (turns - e.turns);	}

	}
	static long dirg[][];
	static Edge[] driver;

	static int n;
		static class Edge implements Comparable<Edge>
	{
		int node; long cost;

		Edge(int a, long dirg) { node = a;	cost = dirg; }

		public int compareTo(Edge e){ return (int) (cost - e.cost);	}
	}

	  static long manhatandistance(long x,long x2,long y,long y2) {
		  return  Math.abs(x-x2)+Math.abs(y-y2);
	  }
	  static long fib[];
	  static long fib(int n) {
		  if(n==1||n==0) {
			  return 1;
		  }
		  if(fib[n]!=-1) {
			  return fib[n];
		  }
		  else
			  return  fib[n]=  ((fib(n-2)%mod+fib(n-1)%mod)%mod);
	  }
	  static class Pair implements Comparable<Pair>{
		  long val;
		  int idx;
		  Pair(int a, long b){
			  idx=a;
			  val=b;
		  }
		public int compareTo(Pair p) {

			return (int) (this.val-p.val);
		}

	}
	static long[][] comb;
	static long nCr1(int n , int k)
	{
		if(n < k)
			return 0;
		if(k == 0 || k == n)
			return 1;
		if(comb[n][k] != -1)
			return comb[n][k];
		if(n - k < k)
			return comb[n][k] = nCr1(n, n - k);
		return comb[n][k] = (nCr1(n - 1, k - 1) + nCr1(n - 1, k))%mod;
	}

static  class Triple implements Comparable<Triple>{

int t;
int burn;
		int cost;
		int idx;
		public Triple(int a,int b,int l,int i) {
			t=a;
			burn=b;
			cost=l;
			idx=i;
		}
		@Override
		public int compareTo(Triple o) {
			return Long.compare( burn,o.burn);
		}

	}

	static TreeSet<Long> primeFactors(long N)		// O(sqrt(N) / ln sqrt(N))
	{
		TreeSet<Long> factors = new TreeSet<Long>();		//take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while(p * p <= N)
		{
			while(N % p == 0) { factors.add((long) p); N /= p; }
			if(primes.size()>idx+1)
			p = primes.get(++idx);
			else
				break;
		}

		if(N != 1)						// last prime factor may be > sqrt(N)
			factors.add(N);				// for integers whose largest prime factor has a power of 1
		return factors;
	}

	static boolean visited[];
	/**static int bfs(int s)
	{
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(s);
		int count=0;
		int maxcost=0;
		int dist[]=new int[n];
		dist[s]=0;
		while(!q.isEmpty())
		{

			int u = q.remove();
			if(dist[u]==k) {
				break;
			}
			for(Pair v: adj[u])
			{
				maxcost=Math.max(maxcost, v.cost);

			if(!visited[v.v])	{

				visited[v.v]=true;
				q.add(v.v);
				dist[v.v]=dist[u]+1;
				maxcost=Math.max(maxcost, v.cost);
			}
			}

		}
		return maxcost;
	}**/
	public static boolean FindAllElements(int n, int k) {
	 int sum = k;
     int[] A = new int[k];
      Arrays.fill(A, 0, k, 1);

      for (int i = k - 1; i >= 0; --i) {

           while (sum + A[i] <= n) {

              sum += A[i];
              A[i] *= 2;
          }
      }
      if(sum==n) {
      	return true;
      }
      else
    	return false;
	}

	static long[][] memo;

	static boolean vis2[][];

	static class SegmentTree {		// 1-based DS, OOP

		int N; 			//the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in)
		{
			array = in; N = in.length - 1;
			sTree = new int[N<<1];		//no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N<<1];
			build(1,1,N);
		}

		void build(int node, int b, int e)	// O(n)
		{
			if(b == e)
				sTree[node] = array[b];
			else
			{
				int mid = b + e >> 1;
				build(node<<1,b,mid);
				build(node<<1|1,mid+1,e);
				sTree[node] = sTree[node<<1]+sTree[node<<1|1];
			}
		}

		void update_point(int index, int val)			// O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while(index>1)
			{
				index >>= 1;
				sTree[index] = sTree[index<<1] + sTree[index<<1|1];
			}
		}

		void update_range(int i, int j, int val)		// O(log n)
		{
			update_range(1,1,N,i,j,val);
		}

		void update_range(int node, int b, int e, int i, int j, int val)
		{
			if(i > e || j < b)
				return;
			if(b >= i && e <= j)
			{
				sTree[node] += (e-b+1)*val;
				lazy[node] += val;
			}
			else
			{
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node<<1,b,mid,i,j,val);
				update_range(node<<1|1,mid+1,e,i,j,val);
				sTree[node] = sTree[node<<1] + sTree[node<<1|1];
			}

		}
		void propagate(int node, int b, int mid, int e)
		{
			lazy[node<<1] += lazy[node];
			lazy[node<<1|1] += lazy[node];
			sTree[node<<1] += (mid-b+1)*lazy[node];
			sTree[node<<1|1] += (e-mid)*lazy[node];
			lazy[node] = 0;
		}

		int query(int i, int j)
		{
			return query(1,1,N,i,j);
		}

		int query(int node, int b, int e, int i, int j)	// O(log n)
		{
			if(i>e || j <b)
				return 0;
			if(b>= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			propagate(node, b, mid, e);
			int q1 = query(node<<1,b,mid,i,j);
			int q2 = query(node<<1|1,mid+1,e,i,j);
			return q1 + q2;

		}

	}
	static boolean f2=false;
	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r)	//C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for(int i = 0; i < p; ++i) {
			for(int j = 0; j < r; ++j) {
				for(int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j]+(a2[i][k]%mod * b[k][j]%mod))%mod;
		 C[i][j]%=mod;
				}

			}
		}
		return C;
	}

	static ArrayList<Pair> a1[];
	static int memo1[];

	static boolean vis[];
	static TreeSet<Integer> set=new TreeSet<Integer>();

	static long modPow(long ways, long count, long mod)	// O(log e)
	{
		ways %= mod;
		long res = 1;
		while(count > 0)
		{
			if((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res%mod;
	}

	static long gcd(long ans,long b) {
		if(b==0) {
			return ans;
		}
		return gcd(b,ans%b);
	}
	static int[] isComposite;
	static int[] valid;

	static ArrayList<Integer> primes;
	static ArrayList<Integer> l;
	static void sieve(int N)	// O(N log log N)
	{
		isComposite = new int[N+1];
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();
		l=new ArrayList<>();
		valid=new int[N+1];
		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				l.add(i);
				valid[i]=1;

				for (int j = i*2; j <=N; j +=i) {	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;

					}
			}

		for(int i=0 ; i<primes.size() ; i++) {
			for(int j:primes) {
				if(primes.get(i)*j>N) {
					break;
				}
				valid[primes.get(i)*j]=1;
			}
		}
	}

	public static long[] schuffle(long[] a2) {
		for (int i = 0; i < a2.length; i++) {
			int x=(int)(Math.random()*a2.length);
		long temp=a2[x];
		a2[x]=a2[i];
		a2[i]=temp;
		}
		return a2;
	}
		static int V;
	static long INF=(long) 1E16;

		static class Edge2
		{
			int node;
		long cost;
			long next;
			Edge2(int a, int c,Long long1) { node = a;	cost = long1; next=c;}

		}
static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

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

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

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

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

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

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	static  ArrayList<Integer>adj[];
	static PrintWriter out=new PrintWriter(System.out);
	 public static int mod = 1000000007;

	static Boolean notmemo[][][];
	static int k;
	static long a[];
	static long b[];
	static int m;
	static char c[];
	static int trace[];
	public static void main(String[] args) throws Exception {
	Scanner sc=new Scanner(System.in);
	int t=sc.nextInt();
	label:while(t-->0) {
	int a=sc.nextInt();
	int b=sc.nextInt();
	long start=9;
	long ans=0;
	while(start<b) {
		ans+=a;
		start*=10;
	}
	out.println(ans);

	}

	out.flush();

	}
	static int teams=0;
static long mini[];
static char x[]= {'h','a','r','d'};
static long s[];
static ArrayList<Integer> l1=new ArrayList<>();
static long count=0;

static long dp(int i,int j) {

	if(i>=n) {
	return 0;
}
	if(j==x.length) {
		return INF;
	}

if(memo[i][j]!=-1) {
	return memo[i][j];
}
long ans=INF;
if(c[i]==x[j]) {
ans=Math.min(ans, dp(i+1, j)+b[i]);
ans=Math.min(ans, dp(i+1,j+1));
}
else {
	ans=Math.min(ans, dp(i+1,j));
}

return memo[i][j]=ans;

}

private static int bs(int i) {
	int high=n-1;
	int low=i;
	int ans=-1;
	int count=1;
	while(high>=low) {
	int	mid=(high+low)>>1;
	if(a[mid]-a[i]<=5) {
		ans=mid;
		low=mid+1;
		count=mid-i+1;
	}
	else {
		high=mid-1;

	}
	}
	return count;

}

/**private static void trace(int i, int time) {
if(i==n)
	return;

long ans=dp(i,time);
if(time+a[i].t<a[i].burn&&(ans==dp(i+1,time+a[i].t)+a[i].cost)) {

	trace(i+1, time+a[i].t);

	l1.add(a[i].idx);
    return;
}
    trace(i+1,time);

}**/

	static class incpair implements Comparable<incpair>
{
	int a; long b;
	int idx;
	incpair(int a, long dirg,int i) {this.a = a;	b = dirg; idx=i; }

	public int compareTo(incpair e){ return (int) (b - e.b);	}
}
	static class decpair implements Comparable<decpair>
{
	int a; long b;int idx;

	decpair(int a, long dirg,int i) {this.a = a;	b = dirg; idx=i;}

	public int compareTo(decpair e){ return (int) (e.b- b);	}
}

	static long allpowers[];
	static class Quad implements Comparable<Quad>{
		int u;
		int v;
		char state;
		int turns;
		public Quad(int i, int j, char c, int k) {
		u=i;
		v=j;
		state=c;
		turns=k;
		}
		public int compareTo(Quad e){ return (int) (turns - e.turns);	}

	}
	static long dirg[][];
	static Edge[] driver;

	static int n;
		static class Edge implements Comparable<Edge>
	{
		int node; long cost;

		Edge(int a, long dirg) { node = a;	cost = dirg; }

		public int compareTo(Edge e){ return (int) (cost - e.cost);	}
	}

	  static long manhatandistance(long x,long x2,long y,long y2) {
		  return  Math.abs(x-x2)+Math.abs(y-y2);
	  }
	  static long fib[];
	  static long fib(int n) {
		  if(n==1||n==0) {
			  return 1;
		  }
		  if(fib[n]!=-1) {
			  return fib[n];
		  }
		  else
			  return  fib[n]=  ((fib(n-2)%mod+fib(n-1)%mod)%mod);
	  }
	  static class Pair implements Comparable<Pair>{
		  long val;
		  int idx;
		  Pair(int a, long b){
			  idx=a;
			  val=b;
		  }
		public int compareTo(Pair p) {

			return (int) (this.val-p.val);
		}

	}
	static long[][] comb;
	static long nCr1(int n , int k)
	{
		if(n < k)
			return 0;
		if(k == 0 || k == n)
			return 1;
		if(comb[n][k] != -1)
			return comb[n][k];
		if(n - k < k)
			return comb[n][k] = nCr1(n, n - k);
		return comb[n][k] = (nCr1(n - 1, k - 1) + nCr1(n - 1, k))%mod;
	}

static  class Triple implements Comparable<Triple>{

int t;
int burn;
		int cost;
		int idx;
		public Triple(int a,int b,int l,int i) {
			t=a;
			burn=b;
			cost=l;
			idx=i;
		}
		@Override
		public int compareTo(Triple o) {
			return Long.compare( burn,o.burn);
		}

	}

	static TreeSet<Long> primeFactors(long N)		// O(sqrt(N) / ln sqrt(N))
	{
		TreeSet<Long> factors = new TreeSet<Long>();		//take abs(N) in case of -ve integers
		int idx = 0, p = primes.get(idx);

		while(p * p <= N)
		{
			while(N % p == 0) { factors.add((long) p); N /= p; }
			if(primes.size()>idx+1)
			p = primes.get(++idx);
			else
				break;
		}

		if(N != 1)						// last prime factor may be > sqrt(N)
			factors.add(N);				// for integers whose largest prime factor has a power of 1
		return factors;
	}

	static boolean visited[];
	/**static int bfs(int s)
	{
		Queue<Integer> q = new LinkedList<Integer>();
		q.add(s);
		int count=0;
		int maxcost=0;
		int dist[]=new int[n];
		dist[s]=0;
		while(!q.isEmpty())
		{

			int u = q.remove();
			if(dist[u]==k) {
				break;
			}
			for(Pair v: adj[u])
			{
				maxcost=Math.max(maxcost, v.cost);

			if(!visited[v.v])	{

				visited[v.v]=true;
				q.add(v.v);
				dist[v.v]=dist[u]+1;
				maxcost=Math.max(maxcost, v.cost);
			}
			}

		}
		return maxcost;
	}**/
	public static boolean FindAllElements(int n, int k) {
	 int sum = k;
     int[] A = new int[k];
      Arrays.fill(A, 0, k, 1);

      for (int i = k - 1; i >= 0; --i) {

           while (sum + A[i] <= n) {

              sum += A[i];
              A[i] *= 2;
          }
      }
      if(sum==n) {
      	return true;
      }
      else
    	return false;
	}

	static long[][] memo;

	static boolean vis2[][];

	static class SegmentTree {		// 1-based DS, OOP

		int N; 			//the number of elements in the array as a power of 2 (i.e. after padding)
		int[] array, sTree, lazy;

		SegmentTree(int[] in)
		{
			array = in; N = in.length - 1;
			sTree = new int[N<<1];		//no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new int[N<<1];
			build(1,1,N);
		}

		void build(int node, int b, int e)	// O(n)
		{
			if(b == e)
				sTree[node] = array[b];
			else
			{
				int mid = b + e >> 1;
				build(node<<1,b,mid);
				build(node<<1|1,mid+1,e);
				sTree[node] = sTree[node<<1]+sTree[node<<1|1];
			}
		}

		void update_point(int index, int val)			// O(log n)
		{
			index += N - 1;
			sTree[index] += val;
			while(index>1)
			{
				index >>= 1;
				sTree[index] = sTree[index<<1] + sTree[index<<1|1];
			}
		}

		void update_range(int i, int j, int val)		// O(log n)
		{
			update_range(1,1,N,i,j,val);
		}

		void update_range(int node, int b, int e, int i, int j, int val)
		{
			if(i > e || j < b)
				return;
			if(b >= i && e <= j)
			{
				sTree[node] += (e-b+1)*val;
				lazy[node] += val;
			}
			else
			{
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node<<1,b,mid,i,j,val);
				update_range(node<<1|1,mid+1,e,i,j,val);
				sTree[node] = sTree[node<<1] + sTree[node<<1|1];
			}

		}
		void propagate(int node, int b, int mid, int e)
		{
			lazy[node<<1] += lazy[node];
			lazy[node<<1|1] += lazy[node];
			sTree[node<<1] += (mid-b+1)*lazy[node];
			sTree[node<<1|1] += (e-mid)*lazy[node];
			lazy[node] = 0;
		}

		int query(int i, int j)
		{
			return query(1,1,N,i,j);
		}

		int query(int node, int b, int e, int i, int j)	// O(log n)
		{
			if(i>e || j <b)
				return 0;
			if(b>= i && e <= j)
				return sTree[node];
			int mid = b + e >> 1;
			propagate(node, b, mid, e);
			int q1 = query(node<<1,b,mid,i,j);
			int q2 = query(node<<1|1,mid+1,e,i,j);
			return q1 + q2;

		}

	}
	static boolean f2=false;
	static long[][] matMul(long[][] a2, long[][] b, int p, int q, int r)	//C(p x r) = A(p x q) x (q x r) -- O(p x q x r)
	{
		long[][] C = new long[p][r];
		for(int i = 0; i < p; ++i) {
			for(int j = 0; j < r; ++j) {
				for(int k = 0; k < q; ++k) {
					C[i][j] = (C[i][j]+(a2[i][k]%mod * b[k][j]%mod))%mod;
		 C[i][j]%=mod;
				}

			}
		}
		return C;
	}

	static ArrayList<Pair> a1[];
	static int memo1[];

	static boolean vis[];
	static TreeSet<Integer> set=new TreeSet<Integer>();

	static long modPow(long ways, long count, long mod)	// O(log e)
	{
		ways %= mod;
		long res = 1;
		while(count > 0)
		{
			if((count & 1) == 1)
				res = (res * ways) % mod;
			ways = (ways * ways) % mod;
			count >>= 1;
		}
		return res%mod;
	}

	static long gcd(long ans,long b) {
		if(b==0) {
			return ans;
		}
		return gcd(b,ans%b);
	}
	static int[] isComposite;
	static int[] valid;

	static ArrayList<Integer> primes;
	static ArrayList<Integer> l;
	static void sieve(int N)	// O(N log log N)
	{
		isComposite = new int[N+1];
		isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
		primes = new ArrayList<Integer>();
		l=new ArrayList<>();
		valid=new int[N+1];
		for (int i = 2; i <= N; ++i) 					//can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
			if (isComposite[i] == 0) 					//can loop in 2 and odd integers for slightly better performance
			{
				primes.add(i);
				l.add(i);
				valid[i]=1;

				for (int j = i*2; j <=N; j +=i) {	// j = i * 2 will not affect performance too much, may alter in modified sieve
						isComposite[j] = 1;

					}
			}

		for(int i=0 ; i<primes.size() ; i++) {
			for(int j:primes) {
				if(primes.get(i)*j>N) {
					break;
				}
				valid[primes.get(i)*j]=1;
			}
		}
	}

	public static long[] schuffle(long[] a2) {
		for (int i = 0; i < a2.length; i++) {
			int x=(int)(Math.random()*a2.length);
		long temp=a2[x];
		a2[x]=a2[i];
		a2[i]=temp;
		}
		return a2;
	}
		static int V;
	static long INF=(long) 1E16;

		static class Edge2
		{
			int node;
		long cost;
			long next;
			Edge2(int a, int c,Long long1) { node = a;	cost = long1; next=c;}

		}
static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

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

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

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

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

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

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

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

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


import java.util.*;
public class Program
{
	static long ans(int a,int b){
	    long ans =a;
	    long digits = (b/10)+1;
	    ans*= Math.pow(10,digits);
	    ans+=b;
	    return ans;
	}
	public static void main(String[] args) {
		Scanner s= new Scanner(System.in);
		int t = s.nextInt();

		while(t--!=0){
		    int A= s.nextInt();
		    int B= s.nextInt();
		  //  System.out.println(storage[A-1][B-1]);

		    int count = 0;
		    int c=B;
		    while(c>0){
		        count++;
		        c/=10;
		    }
		    if(B+1==Math.pow(10,count))count++;
		    System.out.println(A*(count-1));
		}
	}
}


import java.util.*;
public class Program
{
	public static void main(String[] args) {
		Scanner s= new Scanner(System.in);
		int t = s.nextInt();

		while(t--!=0){
		    long A= s.nextLong();
		    long B= s.nextLong();
		  //  System.out.println(storage[A-1][B-1]);

		    int count = 0;
		    long c=B;
		    while(c>0){
		        count++;
		        c/=10;
		    }
		    if(B+1==Math.pow(10,count))
		        count++;
		    System.out.println(A*(count-1));
		}
	}
}


import java.util.*;
public class Program
{
	static long ans(int a,int b){
	    long ans =a;
	    long digits = (b/10)+1;
	    ans*= Math.pow(10,digits);
	    ans+=b;
	    return ans;
	}
	public static void main(String[] args) {
		Scanner s= new Scanner(System.in);
		int t = s.nextInt();

// 		for(int i=1;i<size;i++){
// 		    storage[0][i] = storage[0][i-1];
// 		    if(i+2+(i+1)==ans(1,i+1)){
// 		        storage[0][i]+=1;
// 		    }
// 		}
// 		for(int i=1;i<size;i++){
// 		    storage[i][0] = storage[i-1][0];
// 		    if(i+2+(i+1)==ans(i+1,1)){
// 		        storage[i][0]+=1;
// 		    }
// 		}
// 		for(int i=1;i<size;i++){
// 		    for(int j =1;j<size;j++){
// 		        if(i+1+j+1+((i+1)*(j+1))==ans(i+1,j+1)){
// 		            storage[i][j] = 1+storage[i-1][j-1];
// 		        }else{
// 		            storage[i][j] = Math.max(storage[i-1][j],storage[i][j-1]);
// 		        }
// 		    }
// 		}
// 		for(int i =0;i<10;i++){
// 		    for(int  j =0 ;j<10;j++){
// 		        System.out.print(storage[i][j]+" ");
// 		    }
// 		    System.out.println();
// 		}
		while(t--!=0){
		    int A= s.nextInt();
		    int B= s.nextInt();
		  //  System.out.println(storage[A-1][B-1]);
		    int count = 0;
		    while(B>0){
		        count++;
		        B/=10;
		    }
		    System.out.println(A*(count-1));
		}
	}
}


import java.util.Scanner;

public class Yet_another_meme_prob {

//	public static long concat(long a , long b) {
//		long ans = a;
//		int l=0;
//		long x = b;
//		while(x>0) {
//			l++;
//			x /= 10;
//		}
//		ans *= Math.pow(10, l);
//		int i=0;
//		while(b>0) {
//			ans += (b%10)*Math.pow(10, i);
//			i++;
//			b = b/10;
//		}
//		return ans;
//	}
//	public static long meme(long A , long B) {
//		int ans = 0;
//		for(long i=1 ; i<=A ; i++) {
//			for(long j=1 ; j<=B ; j++) {
//				if(i*j + i + j == concat(i,j)) {
//					ans++;
//					System.out.println(i*j + i+j + " = " + concat(i,j) + " i and j = "+ i + " " + j);
//				}
//			}
//		}
//		return ans;
//	}
	public static long niner(long A) {
		long ans = 0;
		long i = 1;
		while(Math.pow(10,i) < A) {
			ans ++;
			i++;
		}
		return ans;
	}
	public static long meme2(long A, long B) {
		long ans = 0;
		// just calculate all factors of 9 11 , 9 111 , 9 1111 ,  and as long it contains that number.
		ans = A*niner(B);
		return ans;
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		//System.out.println(concat(t,20));
		while(t-->0) {
			long A = s.nextLong();
			long B = s.nextLong();
			//long Ans = meme(A,B); method poor !! only 9 gets added to the end of any number to form a pattern !!
			long Ans = meme2(A,B);
			System.out.println(Ans);
		}
	}

}


import java.util.Scanner;

public class Yet_another_meme_prob {

//	public static long concat(long a , long b) {
//		long ans = a;
//		int l=0;
//		long x = b;
//		while(x>0) {
//			l++;
//			x /= 10;
//		}
//		ans *= Math.pow(10, l);
//		int i=0;
//		while(b>0) {
//			ans += (b%10)*Math.pow(10, i);
//			i++;
//			b = b/10;
//		}
//		return ans;
//	}
//	public static long meme(long A , long B) {
//		int ans = 0;
//		for(long i=1 ; i<=A ; i++) {
//			for(long j=1 ; j<=B ; j++) {
//				if(i*j + i + j == concat(i,j)) {
//					ans++;
//					System.out.println(i*j + i+j + " = " + concat(i,j) + " i and j = "+ i + " " + j);
//				}
//			}
//		}
//		return ans;
//	}
	public static long niner(long A) {
		long ans = 0;
		long i = 1;
		while(Math.pow(10,i) < A) {
			ans ++;
			i++;
		}
		return ans;
	}
	public static long meme2(long A, long B) {
		long ans = 0;
		// just calculate all factors of 9 11 , 9 111 , 9 1111 ,  and as long it contains that number.
		if(A>B)
			ans = B*niner(A);
		else
			ans = A*niner(B);
		return ans;
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		//System.out.println(concat(t,20));
		while(t-->0) {
			long A = s.nextLong();
			long B = s.nextLong();
			//long Ans = meme(A,B); method poor !! only 9 gets added to the end of any number to form a pattern !!
			long Ans = meme2(A,B);
			System.out.println(Ans);
		}
	}

}


import java.util.Scanner;

public class Yet_another_meme_prob {

//	public static long concat(long a , long b) {
//		long ans = a;
//		int l=0;
//		long x = b;
//		while(x>0) {
//			l++;
//			x /= 10;
//		}
//		ans *= Math.pow(10, l);
//		int i=0;
//		while(b>0) {
//			ans += (b%10)*Math.pow(10, i);
//			i++;
//			b = b/10;
//		}
//		return ans;
//	}
//	public static long meme(long A , long B) {
//		int ans = 0;
//		for(long i=1 ; i<=A ; i++) {
//			for(long j=1 ; j<=B ; j++) {
//				if(i*j + i + j == concat(i,j)) {
//					ans++;
//					System.out.println(i*j + i+j + " = " + concat(i,j) + " i and j = "+ i + " " + j);
//				}
//			}
//		}
//		return ans;
//	}
	public static long niner(long A) {
		long ans = 0;
		long i = 1;
		while(Math.pow(10,i) - 1 <= A) {
			ans ++;
			i++;
		}
		return ans;
	}
	public static long meme2(long A, long B) {
		long ans = 0;
		// just calculate all factors of 9 11 , 9 111 , 9 1111 ,  and as long it contains that number.
		if(A>B)
			ans = B*niner(A);
		else
			ans = A*niner(B);
		return ans;
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		//System.out.println(concat(t,20));
		while(t-->0) {
			long A = s.nextLong();
			long B = s.nextLong();
			//long Ans = meme(A,B); method poor !! only 9 gets added to the end of any number to form a pattern !!
			long Ans = meme2(A,B);
			System.out.println(Ans);
		}
	}

}


import java.util.Scanner;

public class Yet_another_meme_prob {

//	public static long concat(long a , long b) {
//		long ans = a;
//		int l=0;
//		long x = b;
//		while(x>0) {
//			l++;
//			x /= 10;
//		}
//		ans *= Math.pow(10, l);
//		int i=0;
//		while(b>0) {
//			ans += (b%10)*Math.pow(10, i);
//			i++;
//			b = b/10;
//		}
//		return ans;
//	}
//	public static long meme(long A , long B) {
//		int ans = 0;
//		for(long i=1 ; i<=A ; i++) {
//			for(long j=1 ; j<=B ; j++) {
//				if(i*j + i + j == concat(i,j)) {
//					ans++;
//					System.out.println(i*j + i+j + " = " + concat(i,j) + " i and j = "+ i + " " + j);
//				}
//			}
//		}
//		return ans;
//	}
	public static long niner(long A) {
		long ans = 0;
		long i = 1;
		while(Math.pow(10,i) - 1 <= A) {
			ans ++;
			i++;
		}
		return ans;
	}
	public static long meme2(long A, long B) {
		long ans = 0;
		// just calculate all factors of 9 11 , 9 111 , 9 1111 ,  and as long it contains that number.
		//if(A>B)
		//	ans = B*niner(A);
		//else
		ans = A*niner(B);
		return ans;
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int t = s.nextInt();
		//System.out.println(concat(t,20));
		while(t-->0) {
			long A = s.nextLong();
			long B = s.nextLong();
			//long Ans = meme(A,B); method poor !! only 9 gets added to the end of any number to form a pattern !!
			long Ans = meme2(A,B);
			System.out.println(Ans);
		}
	}

}


import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        in.init(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int numCases = in.nextInt();
        for(int i = 0; i < numCases; i++) {
            long bigA = in.nextInt();
            long bigB = in.nextInt();
            out.println(bigA * (int) (Math.log10(bigB)));
        }

        out.close();
    }

    public static String conc(long a, long b) {
        String s = "" + a + b;
        return s;
    }
}

class in {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

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

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

    static String nextLine() throws IOException {
        return reader.readLine();
    }

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


import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        in.init(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int numCases = in.nextInt();
        for (int i = 0; i < numCases; i++) {
            long bigA = in.nextInt();
            long bigB = in.nextInt();
            if (bigB == 9 || bigB == 99 || bigB == 999 || bigB == 9999 || bigB == 99999 || bigB == 999999 || bigB == 9999999 || bigB == 99999999 || bigB == 999999999)
                out.println(bigA * (int) (Math.log10(bigB) + 1));
            else
                out.println(bigA * (int) (Math.log10(bigB)));
        }

        out.close();
    }
}

class in {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

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

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

    static String nextLine() throws IOException {
        return reader.readLine();
    }

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


import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        in.init(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int numCases = in.nextInt();
        for (int i = 0; i < numCases; i++) {
            long bigA = in.nextInt();
            long bigB = in.nextInt();
            if (bigB == 9 || bigB == 99 || bigB == 999 || bigB == 9999 || bigB == 999999 || bigB == 9999999 || bigB == 99999999 || bigB == 999999999)
                out.println(bigA * (int) (Math.log10(bigB) + 1));
            else
                out.println(bigA * (int) (Math.log10(bigB)));
        }

        out.close();
    }
}

class in {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) {
        reader = new BufferedReader(new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

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

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

    static String nextLine() throws IOException {
        return reader.readLine();
    }

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


import java.io.*;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.math.*;
public class Main
{
    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());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
     public static void main (String[] args) throws java.lang.Exception {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
    	int t=sc.nextInt();
    	while(t-->0)
        {
           long n=sc.nextLong(),m=sc.nextLong(),k=0,d=m;
           while(m>0)
           {
             k++;
             m/=10;
           }
           String s=String.valueOf(d);
           char c[]=s.toCharArray();Arrays.sort(c);
           s=String.valueOf(c);
           if(s.indexOf('9')==0 && s.lastIndexOf('9')==s.length()-1)
           k++;
           long p=n*(k-1);
           pw.println(p);
        }
    pw.close();
    }
}