#include using namespace std; int main() { int N; cin >> N; vector v(10, 0); int y = 0; for (int i = 0; i < N; i++) { int A, B, C, D; string R; cin >> A >> B >> C >> D >> R; int& a = v.at(A), & b = v.at(B), & c = v.at(C), & d = v.at(D); if (R == "NO") { a = -1; b = -1; c = -1; d = -1; } else { y++; if (a != -1) a++; if (b != -1) b++; if (c != -1) c++; if (d != -1) d++; } /* for (int j = 0; j < 10; j++) { cout << v.at(j); if (j == 9) { cout << endl; } else { cout << ' '; } }*/ } //cout << "y;" << y << endl; int f = -1; for (int i = 0; i < 10; i++) { if (v.at(i) == y) { f = i; } } if (f == -1) { for (int i = 0; i < 10; i++) { if (v.at(i) == -1) { f = i; } } } cout << f << endl; }