#include using namespace std; int main() { int n; cin >> n; set st{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; for (int i = 0; i < n; i++) { int a, b, c, d; string r; cin >> a >> b >> c >> d >> r; if (r == "YES") { for (int j = 0; j < 10; j++) { if (j != a && j != b && j != c && j != d) { st.erase(j); } } } else { st.erase(a); st.erase(b); st.erase(c); st.erase(d); } } cout << *st.begin() << endl; return 0; }