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