#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; } } cout << __lg(ans) << endl; return 0; }