import java.util.*;
public class test{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int t = sc.nextInt();
       for(int i = 0; i<t; i++) {
           int a = sc.nextInt();
           int b = sc.nextInt();
           String str = String.valueOf(a);
           StringBuilder stb = new StringBuilder(str);
           StringBuilder stb2 = new StringBuilder("");

           for(int j=0; j<stb.length(); j++) {

               int temp = Character.getNumericValue(stb.charAt(j));
               temp=temp+b;

               stb2.append(temp);
           }



           





          System.out.println(stb2.length());






       }

    }
}