N=int(input()) T=[] S=[] ans="" Ans=[] for i in range(N): t,s=map(str,input().split()) T.append(t) S.append(s) for i in range(len(T)): if T[i] == "0": Ans.append(S[i]) else: Ans.insert(0,S[i]) for i in range(len(Ans)): ans+=Ans[i] print(ans)