#include #include #include #include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; unordered_set remain{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; for (int i = 0; i < n; ++i) { vector a(4); string s; cin >> a[0] >> a[1] >> a[2] >> a[3] >> s; if (s == "YES") { vector vector1; for (auto x:a) { if (remain.find(x) != remain.end()) { vector1.push_back(x); } } remain.clear(); for (auto x:vector1) { remain.insert(x); } } else { for (auto x:a) { remain.erase(x); } } } for (auto x:remain) { cout << x << endl; } return 0; }