#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=1e5+5;

typedef vector<int> vec;

int n,k,c[N];
bool vis[N];
vec a[7],A,p,q;

vec inv(vec a) {
	vec b;b.resize(n);
	fo(i,0,n-1) b[a[i]]=i;
	return b;
}

vec mult(vec a,vec b) {
	vec c;c.resize(n);
	fo(i,0,n-1) c[i]=a[b[i]];
	return c;
}

vec pwr(vec a,int t) {
	vec b;b.resize(n);
	fo(i,0,n-1) vis[i]=0;
	fo(i,0,n-1)
		if (!vis[i]) {
			if (a[i]==i) {b[i]=i;continue;}
			int x=i,m=0;
			do {vis[c[m++]=x]=1;x=a[x];} while (x!=i);
			fo(j,0,m-1) b[c[j]]=c[(j+t)%m];
		}
	return b;
}

int main() {
	scanf("%d%d",&n,&k);
	p.resize(n);q.resize(n);
	fo(i,0,n-1) scanf("%d",&p[i]),p[i]--;
	fo(i,0,n-1) scanf("%d",&q[i]),q[i]--;
	a[1]=p;a[2]=q;
	if (n<=6) {
		fo(i,3,n) a[i]=mult(a[i-1],inv(a[i-2]));
		fo(i,0,n-1) printf("%d ",a[n][i]+1);
		return 0;
	}
	fo(i,3,6) a[i]=mult(a[i-1],inv(a[i-2]));
	A.resize(n);fo(i,0,n-1) A[i]=i;
	A=mult(A,q);A=mult(A,inv(p));A=mult(A,inv(q));A=mult(A,p);
	A=pwr(A,(k-1)/6);
	vec an=a[(k-1)%6+1];
	an=mult(A,an);an=mult(an,inv(A));
	fo(i,0,n-1) printf("%d ",an[i]+1);
	return 0;
}