while True:
    try:
        num = list(map(int,input().split()))
        n = len(num)
        new = []
        for i in range(2,n-1,2): 
            if num[i+1] not in new: #没有就追加
                new.append(num[i+1])
                new.append(num[i])
            else: #有就插队
                ind = new.index(num[i+1])
                new.insert(ind+1,num[i])
        #循环删除节点
        try:
            while True:
                new.remove(num[-1])
        except:
            pass
        #输出
        new = [str(x) for x in new]
        print(' '.join(new))
    except:
        break