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