#include #include #include int main() { using namespace std; int n; cin >> n; vector> res(n); for (auto &[a, b, c, d, r] : res) { cin >> a >> b >> c >> d >> r;} for (int x = 0; x < 10; x++) { bool ok = true; for (auto [a, b, c, d, r] : res) { if (x == a || x == b || x == c || x == d) { ok &= (r == "YES"); } else { ok &= (r == "NO"); } } if (ok) { cout << x << endl; } } }