#include<bits/stdc++.h>
using namespace std;

const int _ = 1e5 + 7;
struct permutation{
	int arr[_];
	void input(int len){arr[0] = len; for(int i = 1 ; i <= len ; ++i) cin >> arr[i];}
	int& operator [](int x){return arr[x];}
	permutation reverse(){
		permutation temp; temp[0] = arr[0];
		for(int i = 1 ; i <= arr[0] ; ++i) temp[arr[i]] = i;
		return temp;
	}
	friend permutation operator *(permutation p , permutation q){
		permutation temp; for(int i = 1 ; i <= p[0] ; ++i) temp[i] = p[q[i]];
		temp[0] = p[0]; return temp;
	}
	permutation pow(int x){
		bool vis[_] = {}; permutation now; now[0] = arr[0];
		if(x == 0) for(int i = 1 ; i <= arr[0] ; ++i) now[i] = i;
		else
			for(int i = 1 ; i <= arr[0] ; ++i)
				if(!vis[i]){
					int dis = 0 , tmp = i; vector < int > pot;
					do{++dis; vis[tmp] = 1; pot.push_back(tmp); tmp = arr[tmp];}while(tmp != i);
					for(int i = 0 ; i < pot.size() ; ++i) now[pot[i]] = pot[(i + x % pot.size()) % pot.size()];
				}
		return now;
	}
	void output(){for(int i = 1 ; i <= arr[0] ; ++i) cout << arr[i] << ' ';}
}arr[6] , tmp; int N , K;

int main(){
	int N; cin >> N >> K; arr[0].input(N); arr[1].input(N); --K;
	for(int i = 2 ; i < 6 ; ++i) arr[i] = arr[i - 1] * arr[i - 2].reverse();
	tmp = (arr[1] * arr[0].reverse() * arr[1].reverse() * arr[0]).pow(K / 6);
	(tmp * arr[K % 6] * tmp.reverse()).output();
	return 0;
}