#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
using namespace std;
int n,k;struct P
{
	int a[N+5];I P(CI x=0) {for(RI i=1;i<=x;++i) a[i]=i;}
	I int& operator [] (CI x) {return a[x];}I int operator [] (CI x) Con {return a[x];}
 	I friend P operator ~ (Con P& A) {P B;for(RI i=1;i<=n;++i) B[A[i]]=i;return B;}
	I friend P operator * (Con P& A,Con P& B) {P C;for(RI i=1;i<=n;++i) C[i]=A[B[i]];return C;}
}p,q,s,a[10],ans;
I P QP(P x,RI y) {P t=P(n);W(y) y&1&&(t=t*x,0),x=x*x,y>>=1;return t;}
int main()
{
	RI i;for(scanf("%d%d",&n,&k),i=1;i<=n;++i) scanf("%d",&p[i]);for(i=1;i<=n;++i) scanf("%d",&q[i]);
	a[1]=p,a[2]=q,a[3]=a[2]*(~a[1]),a[4]=a[3]*(~a[2]),a[5]=a[4]*(~a[3]),a[6]=a[5]*(~a[4]);
	s=q*(~p)*(~q)*p,ans=QP(s,(k-1)/6)*a[(k-1)%6+1]*QP(~s,(k-1)/6);
	for(i=1;i<=n;++i) printf("%d%c",ans[i]," \n"[i==n]);return 0;
}