#include #include using namespace std; using LL = long long; int main() { int N; cin >> N; set ans; for (int i = 0; i <= 9; i++) ans.insert(i); int ABCD[4]; string R; for (int i = 0; i < N; i++) { for (int i = 0; i < 4; i++) cin >> ABCD[i]; cin >> R; if (R == "YES") { set tmp; for (int j = 0; j < 3; j++) if (ans.find(ABCD[j]) != ans.end()) tmp.insert(ABCD[j]); ans = tmp; } else { for (int j = 0; j < 3; j++) ans.erase(ABCD[j]); } } cout << *ans.begin() << endl; }