#include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int N, A, B, C, D, num[10]; bool dp[6][10]; string S; cin >> N; for (int i = 0; i < N; i++) { for (int j = 0; j < 10; j++) { dp[i][j] = true; } } for (int i = 0; i < N; i++) { cin >> A >> B >> C >> D >> S; if (S == "YES") { for (int j = 0; j < 10; j++) { if (j != A && j != B && j != C && j != D) dp[i][j] = false; } } else { for (int j = 0; j < 10; j++) { if (j == A || j == B || j == C || j == D) dp[i][j] = false; } } } int ans; for (int j = 0 ; j < 10; j++) { bool flag = true; for (int i = 0; i < N; i++) { if (!dp[i][j]) flag = false; } if (flag) { ans = j; break; } } cout << ans << endl; /* fill(num, num+10,1); cin >> N; for (int i = 0; i < N; i++) { cin >> A >> B >> C >> D >> S; if (S == "YES") { for (int j = 0; j < 10; j++) { if (j == A || j == B || j == C || j == D) num[j] += 1; } } else { for (int j = 0; j < 10; j++) { if (j == A || j == B || j == C || j == D) num[j] -= 1; } } } int ans, m = -10; for (int i = 0; i < 10; i++) if (m < num[i]) ans = i, m = num[i]; cout << ans << endl; */ return 0; }