#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<bool> l(10,true);
    for(int i = 0;i < n;i++){
        int a,b,c,d;
        string r;
        cin >> a >> b >> c >> d >> r;
        if(r == "NO"){
            for(int j = 0;j < 10;j++){
                if(j == a || j == b || j == c || j == d)l[j] = false;
            }
        }
        if(r == "YES"){
            for(int j = 0;j < 10;j++){
                if(j == a || j == b || j == c || j == d)continue;
                l[j] = false;
            }
        }
    }
    for(int i = 0;i < 10;i++){
        if(l[i])cout << i << endl;
    }
    return 0;
}