#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

string inv(string x) {
  reverse(begin(x), end(x));
  for (auto&& e : x) e ^= 32;
  return x;
}
string cp(string x, string y) {
  reverse(begin(y), end(y));
  while (!x.empty() and !y.empty() and (x.back() ^ y.back()) == 32) {
    x.pop_back();
    y.pop_back();
  }
  reverse(begin(y), end(y));
  return x + y;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k, --k;
  V<> p(n); for (auto&& e : p) cin >> e, --e;
  V<> q(n); for (auto&& e : q) cin >> e, --e;
  auto cp = [&](const V<>& p, const V<>& q) -> V<> {
    V<> res(n);
    for (int i = 0; i < n; ++i) {
      res[i] = p[q[i]];
    }
    return res;
  };
  auto inv = [&](const V<>& p) -> V<> {
    V<> res(n);
    for (int i = 0; i < n; ++i) {
      res[p[i]] = i;
    }
    return res;
  };
  auto pow = [&](V<> p, int k) -> V<> {
    V<> res(n);
    iota(begin(res), end(res), 0);
    while (k) {
      if (k & 1) res = cp(res, p);
      p = cp(p, p);
      k >>= 1;
    }
    return res;
  };
  auto f = [&](const V<>& p, const V<>& q) -> V<> {
    return cp(q, inv(p));
  };
  auto solve = [&]() -> V<> {
    if (!k) return p;
    VV<> a(7);
    a[0] = p, a[1] = q;
    for (int i = 2; i <= 6; ++i) {
      a[i] = f(a[i - 2], a[i - 1]);
    }
    int r = (k - 1) % 6 + 1;
    auto x = cp(a[3], p);
    x = pow(x, (k - r) / 6);
    auto res = a[r];
    res = cp(x, res);
    res = cp(res, inv(x));
    return res;
  };
  auto res = solve();
  for (int i = 0; i < n; ++i) {
    cout << res[i] + 1 << " \n"[i == n - 1];
  }
}