#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
long long K;

vector<int> idv;
vector<int> p, q, pi, qi;
vector<int> pqpq;

vector<vector<int> > beki;

vector<int> inv(const vector<int> &v) {
    vector<int> res(N);
    for (int i = 0; i < N; ++i) res[v[i]] = i;
    return res;
}

// a b (b が先)
inline vector<int> operator +(const vector<int> &a, const vector<int> &b) {
    vector<int> res(N);
    for (int i = 0; i < N; ++i) res[i] = a[b[i]];
    return res;
}

inline vector<int> pl(const vector<int> &a, const vector<int> &b) {
    vector<int> res(N);
    for (int i = 0; i < N; ++i) res[i] = a[b[i]];
    return res;
}

// r_k
vector<int> calc(long long k) {
    if (k == 0) return idv;
    if (k == 1) return q;
    --k;

    int num = k / 4;
    int r = k % 4;
    vector<int> res = idv;
    if (r == 0) res = idv;
    else if (r == 1) res = pi;
    else if (r == 2) res = pi + qi;
    else if (r == 3) res = pi + qi + p;
    
    auto totyu = idv;
    for (int i = 0; i < 35; ++i) {
        if (num & (1LL<<i)) {
            totyu = totyu + beki[i];
        }
    }
    res = totyu + res;
    res = q + res;
    return res;
}

vector<int> solve(long long k) {
    if (k == 1) return p;
    if (k == 2) return q;
    if (k == 3) return q + pi;
    long long a, b;
    long long d = k / 3;
    if (k % 3 == 0) a = d*2, b = d*2-2;
    else if (k % 3 == 1) a = d*2+1, b = d*2-2;
    else a = d*2+2, b = d*2-1;

    /*
    COUT("---------");
    COUT(k);
    COUT(a);
    COUT(b);
    COUT(calc(a));
    COUT(calc(b));
    */
    
    auto res = calc(a) + inv(calc(b));
    return res;
}

int main() {
    while (cin >> N >> K) {
        idv.resize(N); p.resize(N); q.resize(N);
        for (int i = 0; i < N; ++i) idv[i] = i;
        for (int i = 0; i < N; ++i) cin >> p[i], --p[i];
        for (int i = 0; i < N; ++i) cin >> q[i], --q[i];
        pi = inv(p);
        qi = inv(q);
        pqpq = pi + qi + p + q;
        beki.assign(35, vector<int>());
        beki[0] = pqpq;
        for (int i = 0; i+1 < 35; ++i) {
            beki[i+1] = pl(beki[i], beki[i]);
        }
        auto res = solve(K);
        for (int i = 1; i < 10; ++i) {
            //cout << i << ": " << solve(i) << endl;
        }

        for (auto v : res) {
            cout << v + 1 << " ";
        }
        cout << endl;
    }
}












Measured memory_bytes: 18160