#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef complex<long double> cd;

const int maxn = 2e5 + 5;

int p[maxn], q[maxn], rp[maxn], rq[maxn];
int n;
int rA[maxn], A[maxn], B[maxn];

void power(int b){
	if (b == 0)
		return;
	power(b / 2);
	for (int i = 1; i <= n; i++)
		B[i] = A[A[i]];
	for (int i = 1; i <= n; i++)
		A[i] = B[i];
	if (b & 1){
		for (int i = 1; i <= n; i++)
			B[i] = A[q[rp[rq[p[i]]]]];
		for (int i = 1; i <= n; i++)
			A[i] = B[i];
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> p[i];
		rp[p[i]] = i;
	}
	for (int i = 1; i <= n; i++){
		cin >> q[i];
		rq[q[i]] = i;
	}
	for (int i = 1; i <= n; i++)
		A[i] = i;
	power((k - 1) / 6);
	if (k % 6 == 4){
		for (int i = 1; i <= n; i++)
			B[i] = A[q[i]];
		for (int i = 1; i <= n; i++)
			A[i] = B[i];
	}
	if (k % 6 == 5 or k % 6 == 0){
		for (int i = 1; i <= n; i++)
			B[i] = A[q[rp[i]]];
		for (int i = 1; i <= n; i++)
			A[i] = B[i];
	}
	for (int i = 1; i <= n; i++)
		rA[A[i]] = i;
	k %= 6;
	if (k == 1)
		for (int i = 1; i <= n; i++)
			B[i] = p[i];
	else if (k == 2)
		for (int i = 1; i <= n; i++)
			B[i] = q[i];
	else if (k == 3)
		for (int i = 1; i <= n; i++)
			B[i] = q[rp[i]];
	else if (k == 4)
		for (int i = 1; i <= n; i++)
			B[i] = rp[i];
	else if (k == 5)
		for (int i = 1; i <= n; i++)
			B[i] = rq[i];
	else
		for (int i = 1; i <= n; i++)
			B[i] = rq[p[i]];
	for (int i = 1; i <= n; i++)
		cout << A[B[rA[i]]] << " ";
	cout << endl;
}
