n = int(input()) from collections import deque q = deque([]) for i in range(n): t, s = map(str, input().split()) if t == '0': q.append(s) else: q.appendleft(s) q = list(q) print(''.join(q))