#include using namespace std; typedef long long ll; typedef pair P; const int INF = 1e9; const int mod = 1e9+7; const double EPS = 1e-10; const double PI = acos(-1.0); int dp[10010]; int cnt[10010]; int main() { int n; cin >> n; vector flag(10,1); for(int i = 0; i < n; i++){ int a,b,c,d; string s; cin >> a >> b >> c >> d >> s; for(int j = 0; j < 10; j++){ if(s[0] == 'Y' && (a != j && b != j && c != j && d != j)) flag[j] = 0; if(s[0] == 'N' && (a == j || b == j || c == j || d == j)) flag[j] = 0; } } for(int i = 0; i < 10; i++) if(flag[i]) cout << i << endl; return 0; }