n = int(input()) start = "" end = "" for _ in range(n): t, s = input().split() if t == "1": start += s else: end += s print(start[::-1] + end)