mod = 1000000007 eps = 10**-9 def main(): import sys from collections import deque input = sys.stdin.readline A = deque() N = int(input()) for _ in range(N): t, s = input().split() if t == "0": A.append(s) else: A.appendleft(s) print("".join(A)) if __name__ == '__main__': main()