import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) check = set([str(i + 1) for i in range(9)]) for i in range(n): abcdr = readline().rstrip().decode() abcd = {abcdr[0], abcdr[2], abcdr[4], abcdr[6]} if abcdr[8:] == 'YES': check = check & abcd else: check = check - abcd print(check)