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