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

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

Input

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

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

Output

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

Example

Input


3
1 11
4 2
191 31415926


Output


1
0
1337

Note

There is only one suitable pair in the first test case: a = 1, b = 9 (1 + 9 + 1 ⋅ 9 = 19).
                import java.io.BufferedReader;
                import java.io.FileReader;
                import java.io.IOException;
                import java.io.InputStream;
                import java.io.InputStreamReader;
                import java.io.PrintWriter;
                import java.math.BigInteger;
                import java.util.*;
                    public class Hello {
                    	public static TreeSet<Long> primeFactors(long n)
                        {
                    		TreeSet<Long> res = new TreeSet<Long>();
                            // Print the number of 2s that divide n 
                        while (n % 2 == 0) { 
                            n /= 2;
                            res.add((long) 2);
                        } 
                        
                  
                        // n must be odd at this point.  So we can 
                    // skip one element (Note i = i +2) 
                    for (long i = 3; i <= Math.sqrt(n); i += 2) { 
                        // While i divides n, print i and divide n 
                            while (n % i == 0) { 
                                res.add((long)i);
                                n /= i; 
                            }
                        } 
                  
                        // This condition is to handle the case whien 
                    // n is a prime number greater than 2 
                    if (n > 2) 
                        res.add(n);
                    return res;
                }
                  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 & 1)==1) 
                            res = (res * x) % p; 
                  
                        // y must be even now 
                        // y = y / 2 
                    	            y = y >> 1;  
                    	            x = (x * x) % p;  
                    	        } 
                    	        return res; 
                    	    }
                  public static void f(int[] arr,int n,int[] primes,TreeSet<Integer>prime,StringBuilder res) {
                	  int t = Math.abs(arr[n]-n-1);int idx = 2;
                	  for(int i=0;i<primes.length && t>=primes[i];i++) {
                		  if(prime.contains(t-primes[i])) {
                			  idx = primes[i];
                			  break;
                		  }
                	  }
                	  //System.out.println(idx);
                	  if(arr[n]>n+1) {
                	  int tmp = arr[n];
                	  arr[n] = arr[n+idx-1];
                	  arr[n+idx-1] = tmp;
                	  res.append((n+1)+" " + (n+idx) + "\n");
                	  tmp = arr[n+idx-1];
                	  int tt = arr[n];
                	  arr[n+idx-1] = arr[tt-1];
                	  arr[tt-1] = tmp;
                	  res.append(n+idx + " " + (arr[n])+"\n");
                	  }else {
                    	  int tmp = arr[n];
                    	  arr[n] = arr[n-idx+1];
                    	  arr[n-idx+1] = tmp;
                    	  res.append((n+1)+" " + (n-idx) + "\n");
                    	  tmp = arr[n-idx+1];
                    	  int tt = arr[n];
                    	  arr[n-idx+1] = arr[tt-1];
                    	  arr[tt-1] = tmp;
                    	  res.append(n-idx + " " + (arr[n])+"\n");
                	  }
                		
                  }
                  
                	    static PrintWriter pw = new PrintWriter(System.out);
                	public static void main(String[] args) throws IOException {
                		Scanner sc = new Scanner(System.in);
                		int q = sc.nextInt();
                		while(q-->0) {
                			long a = sc.nextInt();
                			long b = sc.nextInt();
                			long c = 0;
                			for(int i=1;i-1<=b;i*=10) {
                				c++;
                			}
                			//System.out.println(">>"+c);
                			pw.println((c-1)*a);
                		}
                		pw.flush();
                		pw.close();
                	}
                }
                     class card implements Comparable<card>{
                    	int a; int n;
                    	public card(int x,int y) {
                    		a=x;n=y;
                    	}
                    	public int compareTo(card c) {
                    		if(n<c.n)return -1;
                    		if(n>c.n)return 1;
                    		return 0;
                    	}
                    }
                    class Scanner {
                        StringTokenizer st;
                        BufferedReader br;
                     
                        public Scanner(FileReader r) {
                            br = new BufferedReader(r);
                        }
                     
                        public Scanner(InputStream s) {
                            br = new BufferedReader(new InputStreamReader(s));
                        }
                     
                        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 {
                            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();
                            
                        }
                    }