#include using namespace std; int main(){ int n; while(cin >> n){ int t[10] = {0}; for(int i = 0; i < n; i++){ int s[4]; for(int j = 0; j < 4; j++) cin >> s[j]; string flg; cin >> flg; if(flg == "YES"){ for(int j = 0; j < 4; j++){ if(t[s[j]] == -1) continue; t[s[j]]++; } } else{ for(int j = 0; j < 4; j++){ t[s[j]] = -1; } } } int ans = 0; for(int i = 0; i < 10; i++){ if(t[ans] < t[i]){ ans = i; } } cout << ans << endl; } }