N=int(input()) a='' b='' for i in range(N): s=input() if s[0]=='0': a+=s[2] else: b+=s[2] print(b[::-1]+a)