using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public static void Main() {
int X = Convert.ToInt32(Console.ReadLine());
string result = "";
Console.ReadKey();
Console.ReadKey();
for (int i = 0; i < X; i++) {
// string[] inputs = new string[4];
// for (int j = 0; j < 4; j++) {
// inputs[j] = Console.ReadLine();
// }
List<string> inputs = new List<string>();
string[] prefixes = {"A.", "B.", "C.", "D."};
for (int j = 0; j < prefixes.Length; j++) {
// StringBuilder input = new StringBuilder(ReadStringWithPrefix(
// prefixes[(j + 1) % 4]));
StringBuilder input = new StringBuilder(Console.ReadLine());
input.Insert(0, prefixes[j]);
string inputt = input.ToString();
inputs.Add(inputt);
}
int[] lengths = inputs.Select(s => s.Length).ToArray();
int maxLength = lengths.Max();
int maxCount = lengths.Count(l => l == maxLength);
int minLength = lengths.Min();
int minCount = lengths.Count(l => l == minLength);
char recordChar;
if (maxCount == 1 && minCount != 1) { // 唯一最大
int maxIndex = Array.IndexOf(lengths, maxLength);
recordChar = inputs[maxIndex][0];
} else if (minCount == 1 && maxCount != 1) { // 唯一最小
int minIndex = Array.IndexOf(lengths, minLength);
recordChar = inputs[minIndex][0];
} else { // 非唯一最大或最小
recordChar = 'C';
}
result += recordChar;
}
foreach (char c in result) {
Console.WriteLine(c);
}
}
// private static string ReadStringWithPrefix(String prefix) {
// string input = "";
// string line;
// bool isReading = false;
// //读取所有行
// while ((line = Console.ReadLine()) != null) {
// if (line.StartsWith(prefix, StringComparison.Ordinal)) {
// isReading = true;
// } else {
// input += "\n" + line;
// }
// if (line.StartsWith("A.", StringComparison.Ordinal) ||
// line.StartsWith("B.", StringComparison.Ordinal) ||
// line.StartsWith("C.", StringComparison.Ordinal) ||
// line.StartsWith("D.", StringComparison.Ordinal)) {
// break;
// }
// }
// return input;
// }
}