#include using namespace std; int main() { int N; cin >> N; set ans = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; for (int i = 0; i < N; ++i) { int a, b, c, d; string s; cin >> a >> b >> c >> d >> s; set st = {a, b, c, d}; if (s == "YES") { vector vt; set_intersection(ans.begin(), ans.end(), st.begin(), st.end(), back_inserter(vt)); ans.clear(); for (auto x:vt) ans.insert(x); } else { ans.erase(a); ans.erase(b); ans.erase(c); ans.erase(d); } } for (auto x:ans) cout << x << endl; return 0; }