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