import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


int N, K;
int[] P, Q;

int[] inv(in int[] a) {
  int[] b = new int[N];
  foreach (i; 0 .. N) {
    b[a[i]] = i;
  }
  return b;
}

int[] mul(in int[] a, in int[] b) {
  int[] c = new int[N];
  foreach (i; 0 .. N) {
    c[i] = a[b[i]];
  }
  return c;
}

int[] power(in int[] a, int e) {
  int[] b = a.dup;
  int[] c = new int[N];
  foreach (i; 0 .. N) {
    c[i] = i;
  }
  for (; e; e >>= 1) {
    if (e & 1) {
      c = c.mul(b);
    }
    b = b.mul(b);
  }
  return c;
}

void main() {
  try {
    for (; ; ) {
      N = readInt();
      K = readInt();
      P = new int[N];
      foreach (i; 0 .. N) {
        P[i] = readInt() - 1;
      }
      Q = new int[N];
      foreach (i; 0 .. N) {
        Q[i] = readInt() - 1;
      }
      
      int[] ans;
      if (K == 1) {
        ans = P;
      } else if (K == 2) {
        ans = Q;
      } else {
        const x = (K + 1) * 2 / 3;
        const y = (K - 3) * 2 / 3;
        debug {
          writefln("x = %s, y = %s", x, y);
        }
        int[] invP = P.inv;
        int[] invQ = Q.inv;
        int[] R = Q.mul(invP).mul(invQ).mul(P);
        int[] a = R.power(x / 4);
        foreach (i; 0 .. x % 4) {
          a = a.mul([Q, invP, invQ, P][i]);
        }
        int[] b = R.power(y / 4);
        foreach (i; 0 .. y % 4) {
          b = b.mul([Q, invP, invQ, P][i]);
        }
        ans = a.mul(b.inv);
      }
      foreach (i; 0 .. N) {
        if (i > 0) {
          write(" ");
        }
        write(ans[i] + 1);
      }
      writeln();
    }
  } catch (EOFException e) {
  }
}
