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