#include #include using namespace std; int main() { int n; cin >> n; bitset<10> num; num.set(); for (int i = 0; i < n; i++) { int xs[4]; string r; for (int j = 0; j < 4; j++) { int x; cin >> x; xs[j] = x; } cin >> r; if (r == "YES") { bitset<10> yes{}; for (int x : xs) yes.set(x); num &= yes; } else { for (auto x : xs) num.reset(x); } } for (int i = 0; i < 10; i++) { if (num[i] == 1) cout << i << endl; } return 0; }