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

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

Input

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

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

Output

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

Example

Input


3
1 11
4 2
191 31415926


Output


1
0
1337

Note

There is only one suitable pair in the first test case: a = 1, b = 9 (1 + 9 + 1 ⋅ 9 = 19).
//package MyJavaProject;
 
import java.util.*;
import java.lang.Math;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigInteger;  

public class Test 
{
	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; 
	        } 
	    }


	static void print(String s)
	{
		System.out.print(s);
	}
	static void print(boolean s)
	{
		System.out.print(s);
	}
	 
	static long power(long x, long y)
	{
			long p=1000000007;
	        // Initialize result 
	        long res = 1;      
	         
	        // Update x if it is more   
	        // than or equal to p 
	        x = x % p;  
	  
	        if (x == 0) return 0; // In case x is divisible by p;    
	  
	        while (y > 0) 
	        { 
	            // If y is odd, multiply x 
	            // with result 
	            if((y & 1)==1) 
	                res = (res%p * x%p) % p; 
	      
	            // y must be even now 
	            // y = y / 2 
	            y = y >> 1;  
	            x = (x%p * x%p) % p;  
	        } 
	        return res; 
	    }
	static boolean isPrime(long n) 
	{ 
		// Corner cases 
		if (n <= 1) 
			return false; 
		if (n <= 3) 
			return true; 

		// This is checked so that we can skip 
		// middle five numbers in below loop 
		if (n % 2 == 0 || n % 3 == 0) 
			return false; 

		for (int i = 5; i * i <= n; i = i + 6) 
			if (n % i == 0 || n % (i + 2) == 0) 
				return false; 

		return true; 
	} 

	static FastReader f=new FastReader();
	static long[] inArr(long a[],int n)
	{
		for(int i=0;i<n;i++)
			a[i]=f.nextLong();
		return(a);
	}
	
	static void printSubsets(int set[]) 
    { 
        int n = set.length; 
        Arrays.sort(set);
        for(int i=0;i<n;i++)
        {
        	
        }
       HashMap<Integer,Integer> hm=new HashMap<>();
        for (int i = 0; i < (1<<n); i++) 
        { 
            for (int j = 0; j < n; j++) 
            {
            	if ((i & (1 << j)) > 0) {
                	if(hm.get(set[j])==null)
                	{
                		hm.put(set[j],0);
                	}
                	hm.put(set[j],hm.get(set[j])+1);
                	
                }
            }
              
            
     
                	
            
            	
        } 
    } 
	
  
	 static long gcd(long a, long b) 
	    { 
	    if (a == 0) 
	        return b;  
	    return gcd(b % a, a);  
	    } 
	      
	    // method to return LCM of two numbers 
	 static long lcm(long a, long b) 
	    { 
	        return (a*b)/gcd(a, b); 
	    } 
	 static long power(long x, long y, long p) 
	    { 
	  
	        // Initialize result 
	        long res = 1; 
	  
	        // Update x if it is more than or 
	        // equal to p 
	        x = x % p; 
	  
	        while (y > 0) { 
	  
	            // If y is odd, multiply x 
	            // with result 
	            if (y % 2 == 1) 
	                res = (res * x) % p; 
	  
	            // y must be even now 
	            y = y >> 1; // y = y/2 
	            x = (x * x) % p; 
	        } 
	  
	        return res; 
	    } 
	  
	    // Returns n^(-1) mod p 
	    static long modInverse(long n, long p) 
	    { 
	        return power(n, p - 2, p); 
	    } 
	  
	    // Returns nCr % p using Fermat's 
	    // little theorem. 
	    static long nCrModPFermat(int n, int r) 
	    { 
	    	long p=1000000007;
	  
	        // Base case 
	        if (r == 0) 
	            return 1; 
	  
	        // Fill factorial array so that we 
	        // can find all factorial of r, n 
	        // and n-r 
	        long[] fac = new long[n + 1]; 
	        fac[0] = 1; 
	  
	        for (int i = 1; i <= n; i++) 
	            fac[i] = fac[i - 1] * i % p; 
	  
	        return (fac[n] * modInverse(fac[r], p) 
	                % p * modInverse(fac[n - r], p) 
	                % p) 
	            % p; 
	    } 
	public static void main(String args[]) throws Exception
	{
		
		BufferedWriter w=new BufferedWriter(new OutputStreamWriter(System.out));
		Random rand = new Random();
		int t=f.nextInt();
		int tc=0;
		while(t--!=0)
		{
			long A=f.nextLong();
			long B=f.nextLong();
			long sum=0,lim=0;
			long b1=B;
			while(b1!=0)
			{
				sum+=b1%10;
				b1/=10;
			}
			if(sum==9*Long.toString(B).length())
				lim=Long.toString(B).length();
			else
				lim=Long.toString(B).length()-1;
			sum=0;
			for(int i=1;i<=lim;i++)
			{
				sum+=A;
			}
			w.write(sum+"\n");
		}
		w.flush();
		
		
		
		
	}
}