from collections import deque n = int(input()) d = deque() for _ in range(n): t,s = input().split() if t == "0": d.append(s) elif t == "1": d.appendleft(s) ans = "".join(list(d)) print(ans)