#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using std::cin; using std::cout;
using std::endl;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::stringstream; using std::vector;
using std::pair; using std::make_pair;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<ULL, ULL> puu;
#ifdef DEBUG
using std::cerr;
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)                      \
	{                                           \
		cerr << #a << " = {";                   \
		for (int qwq = (st); qwq <= (n); ++qwq) \
			if (qwq == (st))                    \
				cerr << a[qwq];                 \
			else                                \
				cerr << ", " << a[qwq];         \
		cerr << "}" << endl;                    \
	}
#define displayv(a) displaya(a, 0, (int)(a.size() - 1))
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#include <ctime>
class MyTimer {
	clock_t st;
public:
	MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
	~MyTimer() { report(); }
	void reset() { st = clock_t(); }
	void report() {  cerr << "Time consumed: " << (clock() - st) * \
		1e3 / CLOCKS_PER_SEC << "ms" << endl; }
} myTimer;
#else
#define cerr if(false) std::cout
#define pass ;
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(a) ;
#define eprintf(...) if(0) fprintf(stderr, __VA_ARGS__)
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename A, typename B>
std::ostream& operator << (std::ostream &cout, const pair<A, B> &x) {
	return cout << "(" << x.first << ", " << x.second << ")";
}
template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }

const int maxN = 100000 + 233;
const int maxK = 1000000000 + 233;
int n, k;
vector<int> p, q;

vector<int> inv(const vector<int> &x) {
	vector<int> a(x.size());
	for(int i = 0; i < n; ++i) a[x[i]] = i;
	return a;
}
vector<int> comp(const vector<int> &x, const vector<int> &y) {
	vector<int> a(x.size());
	for(int i = 0; i < n; ++i) a[i] = y[x[i]];
	return a;
}
void print(const vector<int> &a) {
	for(int i = 0; i < n; ++i) cout << (a[i] + 1) << ' '; cout << endl;
}

vector<int> qpow(vector<int> a, int k) {
	vector<int> r(a.size());
	for(int i = 0; i < n; ++i) r[i] = i;
	while(k) {
		if(k & 1) r = comp(r, a);
		a = comp(a, a); k >>= 1;
	}
	return r;
}
vector<int> pre() {
	int cnt = (k - 1) / 3 * 2 - 1;
	eprintf("k = %d, pre = %d\n", k, cnt);
	auto r = qpow(comp(comp(comp(inv(q), p),q),inv(p)), cnt / 4);
	cnt -= cnt / 4 * 4;
	if(cnt) cnt--, r = comp(r, inv(q));
	if(cnt) cnt--, r = comp(r, p);
	if(cnt) cnt--, r = comp(r, q);
	return r;
}

vector<int> post() {
	vector< vector<int> > off;
	if((k + 1) / 3 % 2 == 1)
		off = {q, p, inv(q), inv(p)};
	else
		off = {inv(q), inv(p), q, p};
	int cnt = (k + 1) / 3 * 2 - 1;
	eprintf("k = %d, post = %d\n", k, cnt);
	auto r = qpow(comp(comp(comp(off[0], off[1]), off[2]), off[3]), cnt / 4);
	cnt -= cnt / 4 * 4;
	if(cnt) cnt--, r = comp(r, off[0]);
	if(cnt) cnt--, r = comp(r, off[1]);
	if(cnt) cnt--, r = comp(r, off[2]);
	return r;
}

void bf() {
	if(k == 1) print(p);
	else if(k == 2) print(q);
	else {
		k -= 2;
		while(k--) {
			auto x = comp(inv(p), q);
			p = q; q = x;
		}
		print(q);
	}
}

/*
10 25
7 10 6 5 4 2 9 1 3 8
4 1 9 2 3 7 8 10 6 5
*/

int main() {
	std::ios::sync_with_stdio(false);
	cin >> n >> k;
	p.resize(n); q.resize(n);
	for(int i = 0; i < n; ++i) cin >> p[i], p[i]--;
	for(int i = 0; i < n; ++i) cin >> q[i], q[i]--;
	if(k <= 6) {
		bf();
	} else {
		vector<int> mid;
		if(k % 6 == 5 || k % 6 == 1) mid = p;
		else if(k % 6 == 0) mid = comp(p, p);
		else if(k % 6 == 2 || k % 6 == 4) mid = inv(p);
		else mid = inv(comp(p, p));
		auto res = comp(comp(pre(), mid), post());
		print(res);
		// bf();
	}
	return 0;
}


Measured memory_bytes: 4960