T = int(input()) from collections import deque q = deque() for _ in range(T): t,s = input().split() if t == '0': q.append(s) else: q.appendleft(s) print("".join(q))