#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vvi; #define rep(i,n) for(ll i=0;i<(n);i++) #define pii pair #define piii pair #define mp make_pair #define pb push_back #define ALL(a) (a).begin(),(a).end() #define FST first #define SEC second const int INF = (INT_MAX/2); const ll LINF = (LLONG_MAX/2); const double eps = 1e-14; const double PI = M_PI; #define DEB cout<<"!"<> n; rep(i,n){ int a,b,c,d; cin >> a>> b>> c >> d; string s; cin >> s; if(s == "YES"){ dp[a]++,dp[b]++,dp[c]++,dp[d]++; }else{ dp[a] = -INF; dp[b] = -INF; dp[c] = -INF; dp[d] = -INF; } } int ans = 0; rep(i,10){ if(dp[ans] < dp[i]) ans = i; if(i==9) cout << ans << endl; } return 0; }