#include #define REP(i,n) for(int i=0; i<(n); i++) using namespace std; struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; int main() { int N{}; cin >> N; vector a(N), b(N), c(N), d(N); vector R(N); REP( i, N ) cin >> a[i] >> b[i] >> c[i] >> d[i] >> R[i]; vector> P{ {0,0},{1,0},{2,0},{3,0},{4,0},{5,0},{6,0},{7,0},{8,0},{9,0} }; REP( i, N ) { REP( j, 10 ) { if( R[i] == "YES" ) { if( a[i] == P[j].first || b[i] == P[j].first || c[i] == P[j].first || d[i] == P[j].first ) { P[j].second += 1; } } if( R[i] == "NO" ) { if( a[i] == P[j].first || b[i] == P[j].first || c[i] == P[j].first || d[i] == P[j].first ) { P[j].second = 0; } else { P[j].second += 1; } } } } int tmp{}, res{}; for( const auto& x : P ) { if( tmp < x.second ) { tmp = x.second; res = x.first; } } cout << res << endl; return 0; }