#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

// ----------------------------------------

const int maxn = 1e5;

int n;

struct Perm {
  int p[maxn];

  int & operator [] (int i) {
    return p[i];
  }

  int operator [] (int i) const {
    return p[i];
  }

  Perm operator * (const Perm &q) const {
    static Perm z;
    for (int i = 0; i < n; ++i) {
      z[i] = p[q[i]];
    }
    return z;
  }

  Perm Inv(void) const {
    static Perm z;
    for (int i = 0; i < n; ++i) {
      z[p[i]] = i;
    }
    return z;
  }

  void Read(void) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", p + i);
      --p[i];
    }
  }

  void Print(void) {
    for (int i = 0; i < n; ++i) {
      printf("%d%c", p[i] + 1, " \n"[i == n - 1]);
    }
  }
} p, q, inv_p, inv_q, A, inv_A;

Perm Iden(void) {
  static Perm p;
  for (int i = 0; i < n; ++i) {
    p[i] = i;
  }
  return p;
}

Perm Pow(const Perm &p0, int x) {
  static Perm p;
  static Perm q;
  p = p0;
  q = Iden();
  for (; x; x >>= 1) {
    if (x & 1) q = q * p;
    p = p * p;
  }
  return q;
}

int main(void) {
  int k;
  scanf("%d%d", &n, &k);
  p.Read();
  q.Read();
  inv_p = p.Inv();
  inv_q = q.Inv();
  A = q * inv_p * inv_q * p;
  int rep = (k - 1) / 6;
  int now = 1;

  A = Pow(A, rep);
  inv_A = A.Inv();
  p = A * p * inv_A;
  q = A * q * inv_A;
  now += rep * 6;

  while (now < k) {
    A = q * p.Inv();
    p = q;
    q = A;
    ++now;
  }
  p.Print();
  return 0;
}
