n = int(input()) hls=[] fls=[] for i in range(n): head, s = input().split() if head == "0": fls.append(s) else: hls.append(s) hls.reverse() print("".join(hls+fls))