from functools import reduce yes = [] no = [] for _ in range(int(input())): *x, r = input().split() x = set(x) if r == 'YES': yes.append(x) else: no.append(x) if yes: ans = reduce(lambda x, y: x & y, yes) else: ans = {str(i) for i in range(10)} for s in no: ans -= s print(*ans)