#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,k;
struct Perm
{
	int p[100005];
	Perm(){memset(p,0,sizeof(p));}
	int&operator[](int i){return p[i];}
	Perm operator*(Perm q)
	{
		Perm a;
		for(int i=1;i<=n;i++)a[i]=p[q[i]];
		return a;
	}
	Perm Inv()
	{
		Perm a;
		for(int i=1;i<=n;i++)a[p[i]]=i;
		return a;
	}
}p,q,ip,iq,t,it,ans,a[10];
Perm quick_pow(Perm x,int a)
{
	Perm ans;
	for(int i=1;i<=n;i++)ans[i]=i;
	while(a)
	{
		if(a&1)ans=ans*x;
		x=x*x;
		a>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)scanf("%d",&q[i]);
	ip=p.Inv();
	iq=q.Inv();
	t=q*ip*iq*p;
	it=t.Inv();
	k=(m-1)/6;
	m-=6*k;
	a[1]=p;
	a[2]=q;
	for(int i=3;i<=6;i++)a[i]=a[i-1]*a[i-2].Inv();
	Perm ans=quick_pow(t,k)*a[m]*quick_pow(it,k);
	for(int i=1;i<=n;i++)printf("%d ",ans[i]);
	printf("\n");
	return 0;
}