#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
vi mul(const vi &a,const vi &b) {
    int n = a.size();
    vi c(n);
    rep(i,0,n) c[i] = a[b[i]];
    return c;
}
vi inv(const vi &a) {
    int n = a.size();
    vi b(n);
    rep(i,0,n) b[a[i]] = i;
    return b;
}
vi ident(int n) {
    vi a(n);
    rep(i,0,n) a[i] = i;
    return a;
}
vi pow(const vi &a, int k) {
    int n = a.size();
    if(k==0) return ident(n);
    vi half = pow(a,k/2);
    vi result = mul(half,half);
    if(k%2==1) result = mul(result,a);
    return result;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vi p(n), q(n);
    rep(i,0,n) {
        cin >> p[i];
        --p[i];
    }
    rep(i,0,n) {
        cin >> q[i];
        --q[i];
    }
    int sides = (k-1)/6;
    int kk = k-sides*6;
    vector<vi> seq(max(3,kk+1));
    seq[1] = p;
    seq[2] = q;
    rep(i,3,kk+1) seq[i]=mul(seq[i-1],inv(seq[i-2]));
    auto a=p, b=q,c=inv(a),d=inv(q);
    auto left = pow(mul(b,mul(c,mul(d,a))),sides);
    auto right = pow(mul(c,mul(b,mul(a,d))),sides);
    auto result = mul(left,mul(seq[kk],right));
    rep(i,0,n) cout << (result[i]+1) << " ";
    cout << "\n";
}
