import sys #N = int(input()) N = int(sys.stdin.readline()) lst1 = [] lst2 = [] ans = '' for i in range(N): #T,S = input().split(' ') T,S = sys.stdin.readline().strip().split(' ') if T == '0': #ans += S lst1.append(S) else: #ans = S + ans lst2.append(S) #print(ans) print(''.join(lst2[::-1]) + ''.join(lst1))