# coding:utf-8 import statistics n = int(input()) ans_num = [i for i in range(10)] taro_list = [] yes_num = [] no_num = [] for i in range(n): taro_list.append(input().split()) for j in range(n): for k in range(4): if taro_list[j][4] == 'NO': no_num.append(int(taro_list[j][k])) else: yes_num.append(int(taro_list[j][k])) if len(yes_num) == 0: ans = set(ans_num) - set(no_num) print(*ans) elif len(no_num) == 0: ans = statistics.mode(yes_num) print(*ans) else: ans = set(yes_num) - set(no_num) print(*ans)