import sys

T = int(input())
lst = list()
len_lst =list([0,0,0,0])

for i in range(T):
    lst.clear()
    for j in range(4):
        lst.append(input())
        len_lst[j]=len(lst[j])
        

    Max = max(len_lst)
    Min = min(len_lst)
    #当最短的就一个,最长的不止1个选最短的
    if(len_lst.count(Min)==1 and len_lst.count(Max)!=1):
            # print(chr(65+len_lst.index(Min)))
            print("ABCD"[len_lst.index(Min)])
    #同上解释
    elif(len_lst.count(Max)==1 and len_lst.count(Min)!=1):
            # print(chr(65+len_lst.index(Max)))
            print("ABCD"[len_lst.index(Max)])
            
    #其他情况选c
    else:
        print("C")