ans = {*range(10)} for _ in range(int(input())): *x, r = input().split() if r == 'YES': ans -= {*range(10)} - {*map(int, x)} else: ans -= {*map(int, x)} print(*ans)