ans='' for _ in range(int(input())): s,t=input().split() if s=='0': ans+=t else: ans=t+ans print(ans)