#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FOF(i,a,b) for(int i=a;i< b;i++)
using namespace std;
const int N=100100;
int n,K;
struct subs{
	int v[N];
	subs iv(){
		subs x;
		FOR(i,1,n) x.v[v[i]]=i;
		return x;
	}
	subs operator * (const subs&x)const{
		subs y;
		FOR(i,1,n) y.v[i]=v[x.v[i]];
		return y;
	}
	subs pw(int K){
		subs x;
		static int vi[N],s[N];
		FOR(i,1,n)if(!vi[i]){
			int m=0;
			for(int u=i;!vi[u];u=v[u]) vi[u]=1,s[m++]=u;
			FOF(j,0,m) x.v[s[j]]=s[(j+K)%m];
		}
		return x;
	}
}p,q,r,w,a[7];
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d",&n,&K);K--;
	FOR(i,1,n) scanf("%d",&p.v[i]);
	FOR(i,1,n) scanf("%d",&q.v[i]);
	r=q*p.iv()*q.iv()*p;
	a[0]=p;a[1]=q;
	FOR(i,2,5) a[i]=a[i-1]*a[i-2].iv();
	r=r.pw(K/6);
	w=r*a[K%6]*r.iv();
	FOR(i,1,n) cout<<w.v[i]<<' ';cout<<'\n';
}