N = int(input()) a = [] b = [] for _ in range(N): t, s = map(str, input().split()) if t == '0': a.append(s) else: b.append(s) print(''.join(list(reversed(b)) + a))