#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)

struct perm {
  vector<int> a;
  perm(int n) : a(n) {}
  int size() { return a.size(); }
  int &operator[](int k) { return a[k]; }
};

perm operator*(perm a, perm b) {
  const int n = a.size();
  perm ans(n);
  REP(i, n) ans[i] = a[b[i]];
  return ans;
}

perm inv(perm a) {
  const int n = a.size();
  perm ans(n);
  REP(i, n) ans[a[i]] = i;
  return ans;
}

perm pow(perm a, int b) {
  const int n = a.size();
  perm ans(n);
  REP(i, n) ans[i] = i;
  while (b > 0) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}

void print(perm a) {
  for (int i = 0; i < a.size(); i++) {
    if (i > 0) cout << ' ';
    cout << a[i] + 1;
  }
  cout << '\n';
}

int main() {
  int N, K;
  cin >> N >> K;
  perm P(N), Q(N);
  REP(i, N) cin >> P[i], P[i]--;
  REP(i, N) cin >> Q[i], Q[i]--;
  auto X = Q * inv(P) * inv(Q) * P;
  auto Y = inv(P) * Q * P * inv(Q);
  vector<perm> A;
  A.push_back(P);
  A.push_back(Q);
  for (int i = 0; i < 5; i++) {
    A.push_back(A[i + 1] * inv(A[i]));
  }
  A.erase(A.begin());
  if (K == 1) {
    print(P);
    return 0;
  }
  K -= 2;
  perm ans = pow(X, K / 6) * A[K % 6] * pow(Y, K / 6);
  print(ans);
}