#include #include #include int main() { int n; std::cin >> n; const std::vector flags{ 1,2,4,8,16,32,64,128,256,512 }; int flag = ~0; for (; n > 0; --n) { int a, b, c, d; std::string res; std::cin >> a >> b >> c >> d >> res; int bit = 0; for (const auto &f : { a, b, c, d }) { bit |= flags.at(f); } if (res == "NO") { flag &= (~bit); } else { flag &= bit; } } for (auto i = 0; i < 10; ++i) { if ((flags.at(i) & flag) != 0) { std::cout << i << std::endl; break; } } return 0; }