head = "" tail = "" N = int(input()) for i in range(N): T, S = input().split() if T == "0": tail += S else: head += S print(head[::-1] + tail)