```while True:
    try:
        arr = list(map(int, input().split(' ')))
        arr_fst = arr[1]
        arr_lst = arr[2:-1]
        arr_del = arr[-1]
        tmp = [arr_fst]
        for i in range(0, len(arr_lst), 2):
            a, b = arr_lst[i], arr_lst[i+1]
            c = tmp.index(b)
            tmp.insert(c+1, a)
        tmp.remove(arr_del)
        print(' '.join([str(x) for x in tmp]))
    except:
        break