import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) import collections D=collections.deque() for _ in range(n): t,s=input().split() if t=="0": D.append(s) else: D.appendleft(s) print("".join(D))