#include #define rep(i, n) for(long long i = 0; i < n; i++) #define ALL(v) (v).begin(), (v).end() using namespace std; using lint = long long; int main() { int n; cin >> n; vector ok(10, true); vector cnt(10, 0); int yes = 0; rep(i, n) { vector v(4); rep(j, 4) { cin >> v[j]; } string s; cin >> s; if (s == "YES") { yes++; for (int x : v) { if (ok[x]) { cnt[x]++; } } } else { for (int x : v) { ok[x] = false; } } } rep(i, 10) { if (ok[i] && cnt[i] == yes) { cout << i << endl; } } }