#define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #include #include #include using namespace std; int main() { int n; cin >> n; bool ans[10]; REP(i,10) ans[i]=true; int data[4]; string ret; REP(i,n){ REP(j,4) cin >> data[j]; cin >> ret; if (ret == "YES"){ REP(j,10){ if(!count(data,data+4,j)) ans[j] = false; } } else { REP(j,n) ans[data[j]]=false; } } int answer; REP(i,10) if(ans[i]) answer = i; cout << answer << endl; return 0; }