#include<bits/stdc++.h>
const int N=1e5+5;
int n,k,a[N],b[N],c[N],d[N],e[N],f[N],g[N],i;
inline void in(int*a){for(int i=1;i<=n;++i)scanf("%d",a+i);}
inline void out(int*a){for(int i=1;i<=n;++i)printf("%d%c",a[i],i==n?'\n':' ');}
inline void I(int*a){for(int i=1;i<=n;++i)a[i]=i;}
inline void getinv(int*a){
	static int b[N];
	for(int i=1;i<=n;++i)b[a[i]]=i;
	memcpy(a+1,b+1,n<<2);
}
inline void mul(int*a,int*b,int*c){
	static int ans[N];
	for(int i=1;i<=n;++i)ans[i]=b[a[i]];
	memcpy(c+1,ans+1,n<<2);
}
inline void poww(int*a,int K,int*b){
	static int c[N];memcpy(c+1,a+1,n<<2);I(b);
	for(;K;K>>=1,mul(c,c,c))if(K&1)mul(c,b,b);
}
int main(){
	scanf("%d%d",&n,&k);
	in(a);in(b);if(k==1){out(a);return 0;}
	memcpy(c+1,a+1,n<<2);
	memcpy(d+1,b+1,n<<2);
	getinv(c);getinv(d);
	if(k>7)mul(d,a,e),mul(e,b,e),mul(e,c,e),poww(e,(k-2)/6,e);else I(e);
	if(1<k%6 && k%6<5){memcpy(f+1,b+1,n<<2);if(k%3!=2)mul(c,f,f);if(k%3==1)mul(d,f,f);}
		else{memcpy(f+1,d+1,n<<2);if(k%3!=2)mul(f,a,f);if(k%3==1)mul(f,b,f);}
	if(k>4)mul(a,d,g),mul(g,c,g),mul(g,b,g),poww(g,(k+1)/6,g);else I(g);
	mul(e,f,f);mul(f,g,g);out(g);
	return 0;
}