#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair i_ll; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { vector a(10, true); int N; cin >> N; while (N--) { vector b(10, false); int A, B, C, D; cin >> A >> B >> C >> D; b[A] = b[B] = b[C] = b[D] = true; string R; cin >> R; if (R == "NO") for (int i = 0; i < 10; i++) b[i] = !b[i]; for (int i = 0; i < 10; i++) a[i] = a[i] && b[i]; } for (int i = 0; i < 10; i++) if (a[i]) cout << i << endl; }