while True: try: l = input().split() n = int(len(l[2:-1])/2 + 1) ll = [0]*n ll[0] = l[1] # n = len(l[2:-1])/2 + 1 # print(n) for i in range(2,len(l[2:]),2): ll.insert(ll.index(l[i+1])+1, l[i]) # print(ll) ll.remove(l[-1]) # print(ll[0:int(n)-1]) print(" ".join(ll[0:n-1])) except: break