def find_answer(options):
labeled_options = [f"{chr(65 + i)}: {options[i]}" for i in range(4)]
lengths = [len(option) for option in labeled_options]
min_length = min(lengths)
max_length = max(lengths)
min_count = lengths.count(min_length)
max_count = lengths.count(max_length)
if min_count == 1 and max_count != 1:
return labeled_options[lengths.index(min_length)][0]
elif max_count == 1 and min_count != 1:
return labeled_options[lengths.index(max_length)][0]
else:
return 'C'
T = int(input())
for _ in range(T):
options = [input().strip() for _ in range(4)]
print(find_answer(options))