#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

/*vector<char> s[3];

void output(int ind) {
	REP(i, 0, SZ(s[ind])) {
		putchar(s[ind][i]);
	}
	putchar('\n');
}*/

int n;
int A[MAXN], B[MAXN], a[MAXN], b[MAXN];
int BabA[MAXN], aBAb[MAXN], _left[MAXN], _right[MAXN];
int ans[MAXN];

void output(int *per) {
	REP(i, 0, n) {
		printf("%d ", per[i] + 1);
	}
	putchar('\n');
}

void mul(int * per1, int * per2, int *res) {
	REP(i, 0, n) {
		res[i] = per2[per1[i]];
	}
}

int tmp_per[MAXN];
void mul_by(int *per, int *per_by) {
	REP(i, 0, n) {
		tmp_per[i] = per[i];
	}
	mul(tmp_per, per_by, per);
}

int pow_per[MAXN];
void pow_mod(int * per, int st, int *res) {
	REP(i, 0, n) {
		res[i] = i;
		pow_per[i] = per[i];
	}
	for(; st; st /= 2) {
		if (st & 1) {
			mul_by(res, pow_per);
		}
		REP(i, 0, n) {
			tmp_per[i] = pow_per[i];
		}
		mul(tmp_per, tmp_per, pow_per);
	}
}

void solve(){
	/*s[1].pb('A');
	s[2].pb('B');
	output(1);
	output(2);
	REP(i, 3, 30) {
		int ind = i % 3, ind1 = (i + 1) % 3, ind2 = (i + 2) % 3;
		s[ind] = s[ind2];
		for(int i = SZ(s[ind1]) - 1; i >= 0; i--) {
			char cur = s[ind1][i];
			if (cur == s[ind].back()) {
				s[ind].pop_back();
			} else {
				if (cur <= 'B') {
					cur += 'b' - 'B';
				} else {
					cur -= 'b' - 'B';
				}
				s[ind].pb(cur);
			}
		}
		output(ind);
	}*/
	int k;
	scanf("%d%d", &n, &k);
	REP(i, 0, n) {
		scanf("%d", &A[i]);
		A[i]--;
		a[A[i]] = i;
	}
	REP(i, 0, n) {
		scanf("%d", &B[i]);
		B[i]--;
		b[B[i]] = i;
	}
	
	if (k == 1) {
		output(A);
		return;
	}
	if (k == 2) {
		output(B);
		return;
	}
	
	int l1 = (k / 3 * 2 + k % 3);
	int l2 = ((k - 4) / 3 * 2 + (k - 4) % 3);
	if (k <= 4) {
		l2 = 0;
	}
	
	REP(i, 0, n) {
		BabA[i] = A[i];
	}
	mul_by(BabA, b);
	mul_by(BabA, a);
	mul_by(BabA, B);
	
	REP(i, 0, n) {
		aBAb[i] = b[i];
	}
	mul_by(aBAb, A);
	mul_by(aBAb, B);
	mul_by(aBAb, a);
	
	pow_mod(BabA, l1 / 4, _left);
	pow_mod(aBAb, l2 / 4, _right);
	
	REP(i, 0, n) {
		ans[i] = _right[i];
	}
	if (l2 % 4 >= 1) {
		mul_by(ans, b);
	}
	if (l2 % 4 >= 2) {
		mul_by(ans, A);
	}
	if (l2 % 4 >= 3) {
		mul_by(ans, B);
	}
	if (l1 % 4 >= 3) {
		mul_by(ans, b);
	}
	if (l1 % 4 >= 2) {
		mul_by(ans, a);
	}
	if (l1 % 4 >= 1) {
		mul_by(ans, B);
	}
	mul_by(ans, _left);
	output(ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 8192