N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]

def I(s):

 r=[0 for i in range(N)]

 for i in range(N):r[s[i]]=i

 return r

def T(s,t):

 r=[0 for i in range(N)]

 for i in range(N):r[i]=s[t[i]]

 return r

m=[[0 for i in range(N)] for i in range(6)];A=T(T(T(q,I(p)),I(q)),p);X=(K-1)//6

for i in range(N):m[0][i]=p[i];m[1][i]=q[i]

for i in range(2,6):m[i]=T(m[i-1],I(m[i-2]))

def E(s,k):

 if k==0:

  return [i for i in range(N)]

 elif k==1:

  return s

 elif k%2==0:

  return E(T(s,s),k//2)

 else:

  return T(E(T(s,s),k//2),s)

t=E(A,X);a=T(T(t,m[(K-1)%6]),I(t));print((" ".join([str(i+1) for i in a])))
N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]

def I(s):

 r=[0]*N

 for i in range(N):r[s[i]]=i

 return r

def T(s,t):return [s[t[i]] for i in range(N)]

m=[[0 for i in [0]*N] for i in [0]*6]

for i in range(N):m[0][i]=p[i];m[1][i]=q[i]

for i in range(4):m[i+2]=T(m[i+1],I(m[i]))

def E(s,k):

 if k%2==0:

  return E(T(s,s),k//2) if k!=0 else list(range(N))

 else:

  return T(E(T(s,s),k//2),s)

t=E(T(T(T(q,I(p)),I(q)),p),~-K//6);print((" ".join([str(i+1) for i in T(T(t,m[~-K%6]),I(t))])))
N, K = list(map(int, input().split()))
p = [int(i) - 1 for i in input().split()]
q = [int(i) - 1 for i in input().split()]


def I(s):
    r = [0 for i in range(N)]
    for i in range(N):
        r[s[i]] = i
    return r


def T(s, t):
    r = [0 for i in range(N)]
    for i in range(N):
        r[i] = s[t[i]]
    return r


m = [[0 for i in range(N)] for i in range(6)]
A = T(T(T(q, I(p)), I(q)), p)
X = (K - 1) // 6
for i in range(N):
    m[0][i] = p[i]
    m[1][i] = q[i]
for i in range(2, 6):
    m[i] = T(m[i - 1], I(m[i - 2]))


def E(s, k):
    if k == 0:
        return [i for i in range(N)]
    elif k == 1:
        return s
    elif k % 2 == 0:
        return E(T(s, s), k // 2)
    else:
        return T(E(T(s, s), k // 2), s)


t = E(A, X)
a = T(T(t, m[(K - 1) % 6]), I(t))
print((" ".join([str(i + 1) for i in a])))

N, K = list(map(int, input().split()))
p = [int(i) - 1 for i in input().split()]
q = [int(i) - 1 for i in input().split()]


def I(s):
    r = [0] * N
    for i in range(N):
        r[s[i]] = i
    return r


def T(s, t):
    return [s[t[i]] for i in range(N)]


m = [[0 for i in [0] * N] for i in [0] * 6]
for i in range(N):
    m[0][i] = p[i]
    m[1][i] = q[i]
for i in range(4):
    m[i + 2] = T(m[i + 1], I(m[i]))


def E(s, k):
    if k % 2 == 0:
        return E(T(s, s), k // 2) if k != 0 else list(range(N))
    else:
        return T(E(T(s, s), k // 2), s)


t = E(T(T(T(q, I(p)), I(q)), p), ~-K // 6)
print((" ".join([str(i + 1) for i in T(T(t, m[~-K % 6]), I(t))])))

-    r = [0 for i in range(N)] +    r = [0] * N -    r = [0 for i in range(N)] -    for i in range(N): -        r[i] = s[t[i]] -    return r +    return [s[t[i]] for i in range(N)] -m = [[0 for i in range(N)] for i in range(6)] -A = T(T(T(q, I(p)), I(q)), p) -X = (K - 1) // 6 +m = [[0 for i in [0] * N] for i in [0] * 6] -for i in range(2, 6): -    m[i] = T(m[i - 1], I(m[i - 2])) +for i in range(4): +    m[i + 2] = T(m[i + 1], I(m[i])) -    if k == 0: -        return [i for i in range(N)] -    elif k == 1: -        return s -    elif k % 2 == 0: -        return E(T(s, s), k // 2) +    if k % 2 == 0: +        return E(T(s, s), k // 2) if k != 0 else list(range(N)) -t = E(A, X) -a = T(T(t, m[(K - 1) % 6]), I(t)) -print((" ".join([str(i + 1) for i in a]))) +t = E(T(T(T(q, I(p)), I(q)), p), ~-K // 6) +print((" ".join([str(i + 1) for i in T(T(t, m[~-K % 6]), I(t))])))