L = [] for _ in range(int(input())): T, S = input().split() if T == '0': L += [S] else: L.insert(0, S) print(''.join(L))