from collections import deque n = int(input()) ts = [list(input().split()) for _ in range(n)] dq = deque([]) for t, s in ts: if t == "0": dq.append(s) else: dq.appendleft(s) ans = "".join(dq) print(ans)