#include using namespace std; #define dump(x) cout << (x) << '\n' #define Int int64_t #define fi first #define se second #define all(x) (x).begin(), (x).end() Int INF = 1e18; int inf = 1e9; Int mod = 1e9+7; int main() { Int n; cin >> n; vector no(10, false); for (Int i = 0; i < n; i++) { Int a, b, c, d; string s; cin >> a >> b >> c >> d >> s; if (s == "YES") { for (Int j = 0; j <= 9; j++) { if (j != a and j != b and j != c and j != d) { no[j] = true; } } } else { no[a] = no[b] = no[c] = no[d] = true; } } for (Int i = 0; i <= 9; i++) { if (not no[i]) { dump(i); } } return 0; }