思路:

👍最后的空格

代码:

while True:
    try:
        l = input().split()
        head = l[1]
        rm = l[-1]
        l = l[2:-1]
        res = [head]
        for i in range(0, len(l), 2):

            # i = i*2
            # if i>len(l):
            #     break
            a = l[i]
            b = l[i+1]
            res.insert(res.index(b)+1, a)

        res.remove(rm)
        print(' '.join(res)+" ")
    except:
        break