n=int(input()) head='' tail='' for _ in range(n): t,s=map(str,input().split()) if t=='0': tail+=s else: head+=s ans=head[::-1]+tail print(ans)