import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Money {
public static int[] mark=new int[12];
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int ncase=sc.nextInt();
for(int i=0;i<ncase;i++){
String[][] data=new String[3][3];
for(int j=0;j<3;j++){
String oneStr=sc.next();
String twoStr=sc.next();
String threeStr=sc.next();
//mei ge case chu li de
/* for(int k=0;k<3;k++){//那个字母有问题置1,没有问题置2
if(str[k][2].charAt(0)=='e'){
for(int w=0;w<str[k][0].length();w++){
mark[str[k][0].charAt(w)-'A']=2;
}
for(int w=0;w<str[k][1].length();w++){
mark[str[k][1].charAt(w)-'A']=2;
}
}else{
for(int w=0;w<str[k][0].length();w++){
int temp=str[k][0].charAt(w)-'A';
if(mark[temp]==0)
mark[temp]=1;
}
for(int w=0;w<str[k][1].length();w++){
int temp=str[k][1].charAt(w)-'A';
if(mark[temp]==0)
mark[temp]=1;
}
for(int l=0;l<12;l++){
if(mark[l]==0)
mark[l]=2;
}
}
}*/
}
}
}
}