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