N = int(input()) lst = [] ans = '' for i in range(N): T,S = input().split(' ') if T == '0': ans += S else: ans = S + ans print(ans)