#include #include using namespace std; int main(void) { int N = 0; int n[7][4] = {{0}}; string R[7]; bool no[10] = {false}, yes[10] = {false}, d[10] = {false}; bool f = false; cin >> N; for(int i = 0; i < N; i++){ for(int j = 0; j < 4; j++){ cin >> n[i][j]; } cin >> R[i]; } for(int i = 0; i < N; i++){ for(int j = 0; j < 4; j++){ if(R[i] == "NO"){ no[n[i][j]] = true; } else{ if(yes[n[i][j]]){ d[n[i][j]] = true; } yes[n[i][j]] = true; f = true; } } } for(int i = 0; i < 10; i++){ if(!f&&!no[i]){ cout << i << endl; } if(f && ((yes[i] && !no[i]) && d[i])){ cout << i << endl; } } return 0; }