#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 1000000007
#define N 100009
using namespace std;

int n,m; vi ans,f,a[9];
vi inv(vi a){
	int i; vi f; f.resize(n+1);
	for	(i=1; i<=n; i++) f[a[i]]=i;
	return f;
}
vi mrg(vi a,vi b){
	int i; vi c; c.resize(n+1);
	for (i=1; i<=n; i++) c[i]=b[a[i]];
	return c;	
}
void opt(vi f){
	int i;
	for (i=1; i<=n; i++) printf("%d%c",f[i],i<n?' ':'\n');	
}
int main(){
	scanf("%d%d",&n,&m);
	int i;
	a[1].resize(n+1); a[2].resize(n+1);
	for (i=1; i<=n; i++) scanf("%d",&a[1][i]);
	for (i=1; i<=n; i++) scanf("%d",&a[2][i]);
	if (m==1){ opt(a[1]); return 0; }
	for (i=3; i<=7; i++) a[i]=mrg(inv(a[i-2]),a[i-1]);
	f=mrg(mrg(inv(a[2]),a[1]),mrg(a[2],inv(a[1])));
	int tmp=(m-2)/6;
	m-=tmp*6;
	ans.resize(n+1);
	for (i=1; i<=n; i++) ans[i]=i;
	for (; tmp; tmp>>=1,f=mrg(f,f)) if (tmp&1) ans=mrg(ans,f);
	ans=mrg(mrg(ans,a[m]),inv(ans));
	opt(ans);
	return 0;
}
