import sys input=lambda:sys.stdin.readline().rstrip() N=int(input()) ans=['' for i in range(2)] for i in range(N): p=input().split() ans[int(p[0])]+=p[1] print(ans[1][::-1]+ans[0])