n=int(input()) aa=[list(input().split()) for _ in range(n)] o='' for a in aa: o = a[1]+o if a[0]=='1' else o+a[1] print(o)