#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define inf 2147480000
using namespace std;
int n,k;
struct perm{
	int a[100005];
	perm operator +(const perm &b)const{
		perm c;
		For(i,1,n) c.a[i]=a[b.a[i]];
		return c;
	}
	perm operator -(const perm &b)const{
		perm c,d;
		For(i,1,n) d.a[b.a[i]]=i;
		For(i,1,n) c.a[i]=a[d.a[i]];
		return c;
	}
	void init(){
		For(i,1,n) scanf("%d",&a[i]);
	}
}a,b;
void output(perm a){
	For(i,1,n) printf("%d ",a.a[i]);
}
int main(){
	scanf("%d%d",&n,&k);
	a.init();
	b.init();
	if (k==1) return output(a),0;
	if (k==2) return output(b),0;
	int T=(k-2)/6;
	perm tmp,S;
	For(i,1,n) tmp.a[i]=i;
	S=b-a-b+a;
	for (;T;T>>=1,S=S+S)
		if (T&1) tmp=tmp+S;
	a=tmp+a-tmp;
	b=tmp+b-tmp;
	k-=(k-2)/6*6;
	For(i,3,k){
		perm c=b-a;
		a=b; b=c;
	}
	output(b);
}