#include #include #include void solve() { int n; std::cin >> n; int ans = (1 << 10) - 1; while (n--) { int b = 0; for (int i = 0; i < 4; ++i) { int x; std::cin >> x; b |= (1 << x); } std::string s; std::cin >> s; if (s == "NO") b = ~b; ans &= b; } for (int i = 0; i <= 9; ++i) { if ((ans >> i) & 1) std::cout << i << std::endl; } } int main() { std::cin.tie(nullptr); std::cout.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }