#include using namespace std; typedef long long ll; typedef long double ld; #define rep(i,n) for (int i = 0; i < (n); ++i) templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b mem(200001,-1); int main(){ cin.tie(0); ios::sync_with_stdio(false); int n;cin >> n; vector p(10,true); rep(i,n){ int a,b,c,d;cin >> a >> b >> c >> d; string s;cin >> s; bool q[10]; if(s=="YES"){ memset(q,false,sizeof(q)); q[a]=true; q[b]=true; q[c]=true; q[d]=true; } else{ memset(q,true,sizeof(q)); q[a]=false; q[b]=false; q[c]=false; q[d]=false; } rep(j,10){ p[j]=(p[j]&q[j]); } } rep(i,10){ if(p[i]){ cout << i << endl; return 0; } } }