from collections import deque n = int(input()) ans = deque() for i in range(n): a, b = input().split() if a == "0": ans.append(b) else: ans.appendleft(b) print("".join(ans))