import java.util.*;import java.io.*;
public class contest2
{
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int result[]=new int[n];
      int num,d,m=0,l=0;
      String f="";
        for(int i=0;i<n;i++)
        {
      num=in.nextInt();
      d=in.nextInt();
      while(num>0)
      {
          m=num%10;
       f=f+String.valueOf(m+d);
       num=num/10;
        }
        StringBuffer f2=new StringBuffer(f);
        f2.reverse();
        l=f2.length();
        result[i]=l;
        f="";
        }
        for(int y=0;y<n;y++)
        System.out.println(result[y]);
    }
}