#include <stdio.h>
#include <string.h>
int main() {
int T;
// 输入题目数 T
scanf("%d", &T);
getchar(); // 吸收换行符
while(T--)
{
char options[4][605];
int lengths[4];//储存字符长度
for (int i = 0; i < 4; i++)
{
fgets(options[i], 605, stdin);
lengths[i] = strlen(options[i]);
}
int min_count = 0, max_count = 0;
int min_len = lengths[0], max_len = lengths[0];
// 统计最小长度和最大长度的出现次数
for (int i = 0; i < 4; i++) {
if (lengths[i] < min_len)
{
min_len = lengths[i];
min_count = 1;
}
else if (lengths[i] == min_len)
{
min_count++;
}
if (lengths[i] > max_len)
{
max_len = lengths[i];
max_count = 1;
}
else if (lengths[i] == max_len) {
max_count++;
}
}
// 判断属于哪种情况并输出结果
if (min_count == 1 && max_count != 1)
{
// 三长一短,选最短
for (int i = 0; i < 4; i++)
{
if (lengths[i] == min_len)
{
printf("%c\n", 'A' + i);
break;
}
}
}
else if (max_count == 1 && min_count != 1)
{
// 三短一长,选最长
for (int i = 0; i < 4; i++) {
if (lengths[i] == max_len) {
printf("%c\n", 'A' + i);
break;
}
}
}
else
{
// 参差不齐,选 C
printf("C\n");
}
}
return 0;
}