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