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