#include using namespace std; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector D(10, 0); for (int i = 0; i < N; i++) { vector A(4); string r; for (int j = 0; j < 4; j++) { cin >> A[j]; } cin >> r; if (r == "YES") { for (int j = 0; j < 4; j++) { D[A[j]]++; } } if (r == "NO") { for (int j = 0; j < 4; j++) { D[A[j]]--; } } } int res = 0, pnt = -(1 << 28); for (int i = 0; i < 10; i++) { if (chmax(pnt, D[i])) res = i; } cout << res << '\n'; return 0; }