n=int(input()) lst_yes=[True]*10 for i in range(n): a,b,c,d,r=input().split() a,b,c,d,r=int(a),int(b),int(c),int(d),str(r) if r=="NO": lst_yes[a]=lst_yes[b]=lst_yes[c]=lst_yes[d]=False if r=="YES": for j in range(10): if j not in [a,b,c,d]: lst_yes[j]=False for i in range(10): if lst_yes[i]==True:print(i)