import java.util.Arrays;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        // 三长一短
        // 三短一长
        // 参差不齐
        int n = in.nextInt();// 题目数
        // 答案
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < n; i++) {
            // A B C D
            // 0 1 2 3
            Integer[] arr = new Integer[4];
            for (int j = 0; j < 4; j++) {
                arr[j] = in.next().length();
            }
            // 复制一份
            Integer[] temp = arr.clone();
            Arrays.sort(temp, (a, b)->a - b); // 升序排列

            // 三长一短,且不存在四个选项长度中恰有一个选项的长度严格大于另外三个选项;
            if (temp[0] < temp[1] && !(temp[3]>temp[2])) {
                for (int j = 0; j < 4; j++) {
                    if (temp[0] == arr[j]) {
                        res.append(switchIndexToWord(j)).append("\n");
                        break;
                    }
                }
                // 三短一长,且不存在四个选项长度中恰有一个选项的长度严格小于另外三个选项
            } else if (temp[3] > temp[2] && !(temp[0]<temp[1])) {
                for (int j = 0; j < 4; j++) {
                    if (temp[3] == arr[j]) {
                        res.append(switchIndexToWord(j)).append("\n");
                        break;
                    }
                }
            } else {
                // 参差不齐 C
                res.append("C").append("\n");
            }
        }
        // 去除最后一个换行符
        System.out.println(res.substring(0,res.length()-1).toString());
    }

    private static String switchIndexToWord(int index) {
        return 0 == index ? "A" : (1 == index ? "B" : (2 == index ? "C" : "D"));
    }
}