w = "" for _ in range(int(input())): a,b = input().split() if a == "0": w += b else: w = b+w print(w)