#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef vector<int> vi;

const int N = 100010;

vi operator*(const vi& a, const vi& b)
{
	vi res(a.size());
	for (int i = 1; i < a.size(); ++i) res[i] = a[b[i]];
	return res;
}

vi inv(const vi& a)
{
	vi res(a.size());
	for (int i = 1; i < a.size(); ++i) res[a[i]] = i;
	return res;
}

/*vi qpow(const vi& a, int y)
{
	vi res(a.size());
	static vector<bool> vis(a.size(), false);
	for (int i = 1; i < a.size(); ++i)
	{
		if (vis[i]) continue;
		vi cycle(1, a[i]);
		for (int u = a[i]; u != i; u = a[u])
		{
			cycle.push_back(u);
			vis[u] = true;
		}
		for (int j = 0; j < cycle.size(); ++j) res[cycle[j]] = cycle[(j + y) % cycle.size()];
	}
	return res;
}*/

vi qpow(vi x, int y)
{
	vi out(x.size());
	for (int i = 1; i < x.size(); ++i) out[i] = i;
	while (y)
	{
		if (y & 1) out = out * x;
		x = x * x;
		y >>= 1;
	}
	return out;
}

int n, k;
vi f[10], g, ans;

int main()
{
	scanf("%d%d", &n, &k);
	
	f[1].resize(n + 1);
	f[2].resize(n + 1);
	
	for (int i = 1; i <= n; ++i) scanf("%d", &f[1][i]);
	for (int i = 1; i <= n; ++i) scanf("%d", &f[2][i]);
	for (int i = 3; i <= 5; ++i) f[i] = f[i - 1] * inv(f[i - 2]);
	f[0] = inv(f[2]) * f[1];
	g = f[1] * inv(f[0]) * inv(f[1]) * f[0];
	
	ans = qpow(g, k / 6) * f[k % 6] * qpow(inv(g), k / 6);
	
	for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], " \n"[i == n]);
	
	return 0;
}