#include #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = n - 1; i >= a; i--) using namespace std; using ll = long long; using P = pair; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector ans(10); rep(i, 0, 10) ans[i] = i; rep(i, 0, n) { int v[4]; string s; cin >> v[0] >> v[1] >> v[2] >> v[3] >> s; if (s == "YES") { sort(v, v + 4); int ind = 0; rep(i, 0, 10) { if (i != v[ind]) { ans[i] = -1; } else { ind++; } } } else { for (auto m : v) { ans[m] = -1; } } } rep(i, 0, 10) { if (ans[i] != -1) { cout << ans[i] << endl; return 0; } } }