#pragma GCC optimize("Ofast") #include using i8 = std::int8_t;using i16 = std::int16_t;using i32 = std::int32_t;using i64 = std::int64_t;using u8 = std::uint8_t;using u16 = std::uint16_t;using u32 = std::uint32_t;using u64 = std::uint64_t;using f32 = float;using f64 = double; using vi32 = std::vector;using vu32 = std::vector;using vi64 = std::vector;using vu64 = std::vector;using vvi32 = std::vector;using vvu32 = std::vector;using vvi64 = std::vector;using vvu64 = std::vector;using pi32 = std::pair;using pi64 = std::pair;using si32 = std::set;using si64 =std::set; #define FOR(i,a,b) for(i64 i=(a), i##_len=(b); i(n); ++i) #define RFOR(i,a,b) for(i64 i=(a), i##_len=(b); i>i##_len; --i) #define RFORS(i,n) RFOR(i,n,0) #define ALL(obj) (obj).begin(),(obj).end() #define CLR(ar,val) memset(ar, val, sizeof(ar)) #define SZ(obj) (static_cast(obj.size())) #define cauto const auto& #define pb push_back #define mp make_pair const i32 dx[4]={1,0,-1,0}; const i32 dy[4]={0,1,0,-1}; const i32 INF32 = 0x3F3F3F3F; const i64 INF64 = 0x3F3F3F3F3F3F3F3F; const i64 MOD = 1000000007; template inline bool chmax(T &a, const T &b) { if (a inline bool chmin(T &a, const T &b) { if (b std::istream &operator>>(std::istream &is, std::pair &p) { is >> p.first >> p.second;return is; } template std::ostream &operator<<(std::ostream &os, const std::pair& p) { os << p.first << ' ' << p.second;return os; } template std::istream &operator>>(std::istream &is, std::vector &v) { for(T& in : v) is >> in; return is; } template std::ostream &operator<<(std::ostream &os, const std::vector &v) { for(i32 i = 0; i < SZ(v); i++) os << v[i] << (i+1 != SZ(v) ? " " : ""); return os; } // input int N; // dp table void run() { using namespace std; // your code here cin >> N; vector s(10); REP(i,10) s[i] = true; REP(i,N) { int A,B,C,D; string R; cin >> A >> B >> C >> D >> R; if (R == "NO") { s[A] = false; s[B] = false; s[C] = false; s[D] = false; } else { for (int j = 0; j < 10; j++) { if (j != A && j != B && j != C && j != D) s[j] = false; } } } for (int i = 0; i < 10; i++) { if (s[i]) cout << i << endl; } } int main() { run(); }