N = int(input()) s = [True] * 10 for i in range(N): x = input().split() xx = list(map(int, x[0:4])) for j in range(10): if (j in xx) ^ (x[-1] == 'YES'): s[j] = False for i in range(10): if s[i]: print(i)