#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while(t--){
int k = 0;
char grid[3][3];
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
cin >> grid[i][j];
if(grid[i][j] == '?')
k = i;
}
}
int f[3];
for(int i=0; i<3; i++){
f[i] = 0;
}
for(int j=0; j<3; j++){
int ind = grid[k][j] - 'A';
f[ind]++;
}
char ch;
for(int j=0; j<3; j++){
if(f[j] = 0){
ch = f[j] + 65;
}
}
cout << ch << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgdDsKCWNpbiA+PiB0OwoJd2hpbGUodC0tKXsKCQlpbnQgayA9IDA7CgkJY2hhciBncmlkWzNdWzNdOwoJCWZvcihpbnQgaT0wOyBpPDM7IGkrKyl7CgkJCWZvcihpbnQgaj0wOyBqPDM7IGorKyl7CgkJCQljaW4gPj4gZ3JpZFtpXVtqXTsKCQkJCWlmKGdyaWRbaV1bal0gPT0gJz8nKQoJCQkJCWsgPSBpOwoJCQl9CgkJfQoJCWludCBmWzNdOwoJCWZvcihpbnQgaT0wOyBpPDM7IGkrKyl7CgkJCWZbaV0gPSAwOwoJCX0KCQkKCQlmb3IoaW50IGo9MDsgajwzOyBqKyspewoJCQlpbnQgaW5kID0gZ3JpZFtrXVtqXSAtICdBJzsKCQkJZltpbmRdKys7CgkJfQoJCWNoYXIgY2g7CgkJZm9yKGludCBqPTA7IGo8MzsgaisrKXsKCQkJaWYoZltqXSA9IDApewoJCQkJY2ggPSBmW2pdICsgNjU7CgkJCX0KCQl9CgkJCgkJY291dCA8PCBjaCA8PCBlbmRsOwoJfQoJcmV0dXJuIDA7Cn0=