#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using PIC=pair<int,char>;
int main()
{
int T;cin>>T;
cin.ignore();
for(int i=0;i<T;i++)
{
vector<PIC> options;
string a,b,c,d;
getline(cin,a);
getline(cin,b);
getline(cin,c);
getline(cin,d);
options.push_back({a.size(),'A'});
options.push_back({b.size(),'B'});
options.push_back({c.size(),'C'});
options.push_back({d.size(),'D'});
sort(options.begin(),options.end());
int val_min=options[0].first;
int val_max=options[3].first;
int count_min=0,count_max=0;
for(const auto& p:options)
{
if(p.first==val_min)
{
count_min++;
}
if(p.first==val_max)
{
count_max++;
}
}
bool has_unique_short=(count_min==1);
bool has_unique_long=(count_max==1);
if(has_unique_short&&!has_unique_long)
{
cout<<options[0].second<<endl;
}
else if(!has_unique_short&&has_unique_long)
{
cout<<options[3].second<<endl;
}
else
{
cout<<'C'<<endl;
}
}
return 0;
}