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