n=int(input()) a=[str(i) for i in range(10)] for _ in range(n): *b,r=input().split() if r=='NO': a={*a}-{*b} else: a={*a}&{*b} print(*a)