#include inline long nextInt(void) { long temp; std::cin >> temp; return temp; } int main() { int count[10] = {}; int a, b, c, d; int N; std::string str; std::cin >> N; for(int i = 0; i < N; ++i) { std::cin >> a >> b >> c >> d >> str; if( str == "NO" ) { for(int i = 0; i < 10; ++i) { if( i != a && i != b && i != c && i != d ) { ++count[i]; } } } else { for(int i = 0; i < 10; ++i) { if( i == a || i == b || i == c || i == d ) { ++count[i]; } } } } for(int i = 0; i < 10; ++i) { if( count[i] == N ) { std::cout << i << std::endl; return 0; } } return 0; }