import java.util.*;
public class Main{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
while(n-->0){
Choice[] choice = new Choice[4];
char[] select = {'A','B','C','D'};
for(int i=0;i<4;i++){
String s = in.next();
int len = s.length();
choice[i] = new Choice();
choice[i].s = select[i];
choice[i].n = len;
}
Arrays.sort(choice,Comparator.comparingInt(Choice::get_n));
if(choice[0].n==choice[1].n&&choice[2].n<choice[3].n){
System.out.println(choice[3].s);//三短一长
}else if(choice[2].n==choice[3].n&&choice[0].n<choice[1].n){
System.out.println(choice[0].s);//三长一短
}else System.out.println('C');
}
}
}
class Choice{
public char s;
public int n;
Choice(){
this.n = 0;
}
public int get_n(){
return this.n;
}
}