n = int(input()) num_flag = [True] * 10 for i in range(n): a = list(map(str,input().split())) if a[4] == "NO": for j in range(4): num_flag[int(a[j])] = False else: ten = [j for j in range(10)] for j in range(4): ten.remove(int(a[j])) for j in ten: num_flag[j] = False for i in range(10): if num_flag[i]: print(i)