n=int(input()) s,t='','' for _ in [0]*n: f,c=input().split() if f=='0': s+=c else: t+=c print(t[::-1]+s)