#include [[nodiscard]] static inline constexpr uint_fast32_t solve([[maybe_unused]] const uint_fast32_t N, const std::vector>& hints) noexcept { std::bitset<10> possible_numbers((UINT32_C(1) << 10) - 1); for (const auto& [a, b, c, d, r] : hints) { std::bitset<10> mask((UINT32_C(1) << a) | (UINT32_C(1) << b) | (UINT32_C(1) << c) | (UINT32_C(1) << d)); switch (r[0]) { case 'Y': possible_numbers &= mask; break; case 'N': possible_numbers &= mask.flip(); break; } } [[assume(possible_numbers.count() == 1)]]; for (uint_fast32_t i = 0; i != 10; ++i) if (possible_numbers.test(i)) return i; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N; std::cin >> N; std::vector> hints(N); for (auto& [a, b, c, d, r] : hints) std::cin >> a >> b >> c >> d >> r; std::cout << solve(N, hints) << '\n'; return 0; }