/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner scan = new Scanner(System.in);
int[] noOfSticks={6, 2, 5, 5, 5, 5, 6, 3, 7, 6};
int t = scan.nextInt();
while(t–>0){
int a =scan.nextInt();
int b=scan.nextInt();
int sum=a+b;
int output=0;
int temp;
while(sum>0){
temp=sum%10;
sum=sum/10;
output=output+noOfSticks[temp];
}
System.out.println(output);
}
}
}