from sys import stdin n=int(input()) s=[] for _ in range(n): f,c=stdin.readline().split() s.append(c) if f=='0'else s.insert(0,c) print(''.join(s))