#include <bits/stdc++.h>

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

const int N = 1e5 + 5;

int n, K, p[N], q[N], l[N], r[N], ip[N], iq[N], resl[N], resr[N], tmp[N], mid[N];
// f(n) = (2 -1 -2 1) + f(n - 6) + (-1 2 1 -2)
int main()
{
	read(n); read(K); int mt = K % 6; if (!mt) mt = 6;
	for (int i = 1; i <= n; i++) read(p[i]), ip[p[i]] = i;
	for (int i = 1; i <= n; i++) read(q[i]), iq[q[i]] = i;
	for (int i = 1; i <= n; i++) l[i] = q[ip[iq[p[i]]]], r[i] = ip[q[p[iq[i]]]];
	K = (K - mt) / 6; for (int i = 1; i <= n; i++) resl[i] = resr[i] = i;
	while (K)
	{
		if (K & 1)
		{
			for (int i = 1; i <= n; i++) tmp[i] = l[resl[i]];
			for (int i = 1; i <= n; i++) resl[i] = tmp[i];
			for (int i = 1; i <= n; i++) tmp[i] = r[resr[i]];
			for (int i = 1; i <= n; i++) resr[i] = tmp[i];
		}
		for (int i = 1; i <= n; i++) tmp[i] = l[l[i]];
		for (int i = 1; i <= n; i++) l[i] = tmp[i];
		for (int i = 1; i <= n; i++) tmp[i] = r[r[i]];
		for (int i = 1; i <= n; i++) r[i] = tmp[i];
		K >>= 1;
	}
	for (int i = 1; i <= n; i++)
		if (mt == 1) mid[i] = p[i];
		else if (mt == 2) mid[i] = q[i];
		else if (mt == 3) mid[i] = q[ip[i]];
		else if (mt == 4) mid[i] = q[ip[iq[i]]];
		else if (mt == 5) mid[i] = q[ip[iq[p[iq[i]]]]];
		else mid[i] = q[ip[iq[p[iq[q[p[iq[i]]]]]]]];
	for (int i = 1; i <= n; i++) printf("%d ", resl[mid[resr[i]]]);
	return puts(""), 0;
}