#include <bits/stdc++.h>
#define INF 990000000
//9
using namespace std;


int main() {
int n;
cin>>n;

int res[10];
fill(res,res+10,0);
for(int i=0;i<n;i++){
int a[4];
for(int j=0;j<4;j++)cin>>a[j];
string temp;
cin>>temp;
if(temp.compare("NO")==0){
for(int j=0;j<4;j++)res[a[j]]--;
}else{
for(int j=0;j<4;j++)res[a[j]]++;
}

}
int maxi=0;
for(int i=0;i<10;i++){
maxi=max(maxi,res[i]);
}
for(int i=0;i<10;i++){
if(res[i]==maxi)cout <<i<<endl;
}
//cout <<l+m+n<<endl;



}