#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma comment(linker, "STACK:36777216") using namespace std; using i64 = int64_t; constexpr i64 MOD = 1e9 + 7; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); using vi = vector; using vvi = vector; using vvvi = vector; using ii = pair; int main() { int n; cin >> n; multiset yes, no; for (int i = 1; i < 10; i++) { yes.insert(i); } for (int i = 0; i < n; i++) { multiset tmp; for (int i = 0; i < 4; i++) { int a; cin >> a; tmp.insert(a); } string s; cin >> s; if (s == "YES") { set_intersection(yes.begin(), yes.end(), tmp.begin(), tmp.end(), inserter(yes, yes.end())); } else { set_union(no.begin(), no.end(), tmp.begin(), tmp.end(), inserter(no, no.end())); } } if (yes.size() == 1) { cout << *(yes.begin()) << endl; return 0; } if (yes.size()) { for (int y: yes) { if (no.count(y) == 0) { cout << y << endl; return 0; } } } for (int i = 1; i < 10; i++) { if (no.count(i) == 0) { cout << i << endl; } } }