from collections import deque #両端を扱うなら、listよりdeque N = int(input()) d = deque() for _ in range(N): t, s = input().split() if t == '0': d.append(s) else: d.appendleft(s) print(''.join(list(d)))