#include<bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<vector<string>> a(26);
for(int i = 0; i < n; i ++ ) {
string name, result;
char id;
cin >> name >> id >> res;
if(res == "accepted") {
a[id - 'A'].push_back(name);
}
}
int ans, mx = 0;
for(int i = 0; i < 26; i ++ ) {
sort(a[i].begin(), a[i].end());
a[i].erase(unique(a[i].begin(), a[i].end()), a[i].end());
if(a[i].size() > mx) {
mx = a[i].size();
ans = i;
}
}
cout << char(ans + 'A') << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t -- ) {
solve();
}
return 0;
}