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