#include #include #include #include using namespace std; int main() { int N; vector A(4); string R; set yes; set no; yes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; no.clear(); cin >> N; for( int i = 0; i < N; i++ ) { cin >> A[0] >> A[1] >> A[2] >> A[3] >> R; if( R == "NO" ) { for(auto x: A ) { no.insert(x); } } else { set tmp; tmp.clear(); for(auto x: A ) { tmp.insert(x); } set tmp2; tmp2.clear(); for( auto a: tmp ) { for( auto b : yes ) { if( a == b ) { tmp2.insert(a); } } } yes = tmp2; } } /* cout << "YES" << endl; for( auto x : yes ) { cout << x << endl; } cout << "NO" << endl; for( auto x : no ) { cout << x << endl; } for( auto n : no) { yes.erase( n ); } cout << "ANSWER" << endl; */ for( auto n : no) { yes.erase( n ); } for( auto y : yes ) { cout << y << endl; } return 0; }