from functools import reduce print(*reduce(lambda a, b: a & b, [set(map(int, j[:-1])) if j[-1] == "YES" else set(range(10)) - set(map(int, j[:-1])) for j in [input().split() for i in [0] * int(input())]]))