from collections import deque N = int(input()) ans = deque() for i in range(N): T, S = map(str, input().split()) if T == "1": ans.appendleft(S) else: ans.append(S) print("".join(ans))