#include using namespace std; int main(){ cin.tie(nullptr)->sync_with_stdio(false); int N; cin >> N; int ans = 1023; for(int i = 0; i < N; ++i){ int a, b, c, d; cin >> a >> b >> c >> d; string response; cin >> response; int mask = (1 << a) | (1 << b) | (1 << c) | (1 << d); if(response == "NO"){ ans &= ~mask; } else{ ans &= mask; } } assert(__builtin_popcount(ans) == 1); cout << __lg(ans) << endl; return 0; }