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