#include <bits/stdc++.h> 

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

std::vector<int> a[6], A;
int n, k;

std::vector<int> operator * (const std::vector<int> &a, const std::vector<int> &b) {
	std::vector<int> res(n);
	for (int i = 0; i < n; ++ i) res[i] = a[b[i]];
	return res;
}

std::vector<int> inv(const std::vector<int> &a) {
	std::vector<int> res(n);
	for (int i = 0; i < n; ++ i) res[a[i]] = i;
	return res;
}

std::vector<int> ksm(std::vector<int> x, int y) {
	std::vector<int> res(n);
	for (int i = 0; i < n; ++ i) res[i] = i;
	for (; y; y >>= 1, x = x * x) if (y & 1) res = res * x;
	return res;
}

int main() {
	// freopen("a.in", "r", stdin);
	n = read(), k = read() - 1; a[1].resize(n); a[0].resize(n);
	for (int i = 0; i < n; ++ i) a[0][i] = read() - 1;
	for (int i = 0; i < n; ++ i) a[1][i] = read() - 1;
	for (int i = 2; i < 6; ++ i) a[i] = a[i - 1] * inv(a[i - 2]);
	if (k < 6) { for (int i = 0; i < n; ++ i) printf("%d ", a[k][i] + 1); puts(""); return 0; }
	A = ksm((a[1] * inv(a[0])) * (inv(a[1]) * a[0]), k / 6);
	A = A * a[k % 6] * inv(A);;
	for (int i = 0; i < n; ++ i) printf("%d ", A[i] + 1); puts("");
	return 0;
}