#include #define rep(i,n) for(int i=0;i<(n);++i) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair P; bool ok[10]; int cnt[10]; int main() { fill(ok, ok + 10, true); memset(cnt, 0, sizeof(cnt)); ios_base::sync_with_stdio(0); cin.tie(0); int N; cin >> N; int yescnt = 0; rep (i, N){ int a[4] = {0}; rep (i, 4) cin >> a[i]; string r; cin >> r; if (r == "NO"){ rep (i, 4) ok[a[i]] = false; }else{ // if (r == "YES) ++yescnt; rep (i, 4) ++cnt[a[i]]; } // end if } // end rep rep (i, 10){ if (ok[i] && (cnt[i] == yescnt)){ cout << i << endl; break; } // end if } // end rep return 0; }