n=int(input()) ans="" for i in range(n): t,s=map(str, input().split()) if t=='1': ans = s+ans else: ans = ans+s print(ans)