Sy = set(str(i) for i in range(10)) Sn = set(str(i) for i in range(10)) N = int(input()) for _ in range(N): lst = input().split() if lst[-1][0] == "Y": Sy = Sy.intersection(lst[:-1]) else: Sn = Sn.difference(lst[:-1]) if len(Sy) == 1: print(Sy.pop()) else: print(Sn.pop())