/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
int n,k;
class Perm{
public:
	int to[maxn];
	void init(){
		REP(i,n){
			int x;scanf("%d",&x);
			to[x]=i;
		}
	}
	Perm inv(){
		Perm res;
		REP(i,n)res.to[to[i]]=i;
		return res;
	}
	Perm operator * (const Perm &o)const{
		Perm res;
		REP(i,n)res.to[i]=o.to[to[i]];
		return res;
	}
}id,p,q,cur,a[6],b[6];
Perm quickpow(Perm x,int pow){
	Perm res=id;
	for(;pow;pow>>=1){
		if(pow&1)res=res*x;
		x=x*x;
	}
	return res;
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&k);
	k--;
	p.init();
	q.init();
	REP(i,n)id.to[i]=i;
	a[0]=a[1]=a[2]=id;
	a[3]=b[1]=q;
	a[4]=a[5]=b[2]=q*p.inv();	
	b[0]=p;
	b[3]=p.inv();
    b[4]=q.inv();
    b[5]=q.inv()*p;
	cur=q*p.inv()*q.inv()*p;
	cur=quickpow(cur,k/6)*a[k%6];
	cur=(cur*b[k%6]*cur.inv()).inv();
	REP(i,n)printf("%d ",cur.to[i]);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/
