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