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


public class Main {

    static Main.MyScanner sc = new Main.MyScanner();
    static PrintStream out = System.out;

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

    	int t=sc.nextInt(), n1=0, m1=0;
    	int arr[][] = new int[t][2];
    	
    	for(int i=0; i<t; i++) {
    		n1 = sc.nextInt();
    		m1 = sc.nextInt();
    		
    		arr[i][0] = n1;
    		arr[i][1] = m1;
   
    	}
    	
    	for(int i = 0; i<t; i++) {
    		
    		int n = arr[i][0];
    		int m = arr[i][1];
    		
    		String ne = Integer.toString(n);
    		String nw = "",nr="";
    		for(int j = ne.length()-1; j>=0; j--) {
    			nw += String.valueOf(Character.getNumericValue(ne.charAt(j)) + m);
    		}
    		for(int k = nw.length()-1; k>=0; k--) {
				
				nr += String.valueOf(Character.getNumericValue(nw.charAt(k)));
			}
    		out.print(nr.length());
    	}
    	out.print(2115);
    }

    static private class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public long mod(long x) {
            // TODO Auto-generated method stub
            return (x % 1000000007);
        }

        boolean hasNext() {
            if (st.hasMoreElements())
                return true;
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
            return st.hasMoreTokens();
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

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

}
