from sys import stdin n=int(input()) s='' for i in range(n): f,c=stdin.readline().split() s=s+c if f=='0'else c+s print(s)