#!/usr/bin/python3 # † from collections import deque que = deque() N = int(input()) for _ in range(N): t, s = input().split() t = int(t) if t == 0: que.append(s) else: que.appendleft(s) print(''.join(que))