#include "iostream"
using namespace std;

int main(){
    int n;
    int a,b,c,d;
    int list[] = {0,0,0,0,0,0,0,0,0,0};
    string truth;
    cin>>n;
    while (n--) {
        cin >>a>>b>>c>>d>>truth;

        if (truth == "NO") {
            for (int i=0; i < 10; i++) {

                if (i==a or i==b or i==c or i==d){
                    list[i] =-1;
                }
            }
        } else{
            for (int i=0; i < 10; i++) {
                if (i!=a and i!=b and i!=c and i!=d){
                    list[i] =-1;
                }
            }
        }
    }
    for (int i=0; i < 10; i++) {
        if (list[i]==0){
            cout<<i<<endl;
        }
    }
    return 0;
}