n=int(input()) head=[] end=[] a=0 for i in range(n): t,s = map(str,input().split()) if t=="0": end.append(s) else: head.append(s) a+=1 head.reverse() print("".join(head+end))