#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int N;
int P[100000];
int PT[100000];
int Q[100000];
int QT[100000];
int answer[100000];
int buffer[100000];
int buffer2[100000];
int buffer3[100000];
int buffer4[100000];
void Rev(int* A,int* B){
	for(int i=0;i<N;i++){
		A[B[i]] = i;
	}
}
void Mul(int* A,int* B,int* C){
	for(int i=0;i<N;i++){
		A[i] = B[C[i]];
	}
}
void Pow(int* A,int* B,long K){
	vector<int> ans(N);
	vector<int> ans2(N);
	for(int i=0;i<N;i++){
		ans[i] = i;
	}
	vector<int> T(N);
	vector<int> T2(N);
	for(int i=0;i<N;i++){
		T[i] = B[i];
	}
	while(K){
		if(K & 1){
			swap(ans,ans2);
			for(int i=0;i<N;i++){
				ans[i] = ans2[T[i]];
			}
		}
		swap(T,T2);
		for(int i=0;i<N;i++){
			T[i] = T2[T2[i]];
		}
		K /= 2;
	}
	for(int i=0;i<N;i++){
		A[i] = ans[i];
	}
}
void Calc(){
	N = rei();
	long K = rel()-1;
	for(int i=0;i<N;i++){
		P[i] = rei()-1;
		PT[P[i]] = i;
	}
	for(int i=0;i<N;i++){
		Q[i] = rei()-1;
		QT[Q[i]] = i;
	}
	if(K % 6 == 0){
		Mul(buffer,Q,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Pow(buffer,buffer,K/6);
		Rev(buffer4,buffer);
		Mul(buffer2,buffer,P);
		Mul(answer,buffer2,buffer4);
	}
	else if(K % 6 == 1){
		Mul(buffer,Q,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Pow(buffer,buffer,K/6);
		Rev(buffer4,buffer);
		Mul(buffer2,buffer,Q);
		Mul(answer,buffer2,buffer4);
	}
	else if(K % 6 == 2){
		Mul(buffer,Q,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Pow(buffer,buffer,K/6);
		Rev(buffer4,buffer);
		Mul(buffer2,buffer,Q);
		Mul(buffer,buffer2,PT);
		Mul(answer,buffer,buffer4);
	}
	else if(K % 6 == 3){
		Mul(buffer,Q,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Pow(buffer,buffer,K/6);
		Rev(buffer4,buffer);
		Mul(buffer2,buffer,Q);
		Mul(buffer,buffer2,PT);
		Mul(buffer2,buffer,QT);
		Mul(answer,buffer2,buffer4);
	}
	else if(K % 6 == 4){
		Mul(buffer,Q,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Pow(buffer,buffer,K/6);
		Rev(buffer4,buffer);
		Mul(buffer2,buffer,Q);
		Mul(buffer,buffer2,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Mul(buffer2,buffer,QT);
		Mul(answer,buffer2,buffer4);
	}
	else{
		Mul(buffer,Q,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Pow(buffer,buffer,K/6);
		Rev(buffer4,buffer);
		Mul(buffer2,buffer,Q);
		Mul(buffer,buffer2,PT);
		Mul(buffer2,buffer,QT);
		Mul(buffer,buffer2,P);
		Mul(buffer2,buffer,P);
		Mul(buffer,buffer2,QT);
		Mul(answer,buffer,buffer4);
	}
	for(int i=0;i<N;i++){
		cout << answer[i]+1;
		if(i == N-1){
			cout << endl;
		}
		else{
			cout << " ";
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 4224