// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <list>
#include <ostream>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
template < int n, class... T >
typename std::enable_if< (n >= sizeof...(T)) >::type __output_tuple(
    std::ostream &, std::tuple< T... > const &) {}
template < int n, class... T >
typename std::enable_if< (n < sizeof...(T)) >::type __output_tuple(
    std::ostream &os, std::tuple< T... > const &t) {
  os << (n == 0 ? "" : ", ") << std::get< n >(t);
  __output_tuple< n + 1 >(os, t);
}
template < class... T >
std::ostream &operator<<(std::ostream &os, std::tuple< T... > const &t) {
  os << "(";
  __output_tuple< 0 >(os, t);
  os << ")";
  return os;
}
template < class T, class U >
std::ostream &operator<<(std::ostream &os, std::pair< T, U > const &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template < class T >
std::ostream &operator<<(std::ostream &os, const std::stack< T > &a) {
  os << "{";
  for(auto tmp = a; tmp.size(); tmp.pop())
    os << (a.size() == tmp.size() ? "" : ", ") << tmp.top();
  os << "}";
  return os;
}
template < class T, class Container, class Compare >
std::ostream &operator<<(std::ostream &os,
    std::priority_queue< T, Container, Compare > a) {
  os << "{ (top) ";
  while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
template < class T, class Container >
std::ostream &operator<<(std::ostream &os, std::queue< T, Container > a) {
  os << "{ ";
  while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
#ifdef DEBUG
#if !defined(DEBUG_OUT)
// #define DEBUG_OUT std::cerr
#endif
#define dump(...)                                                                \
  [&]() {                                                                        \
    auto __debug_tap = std::make_tuple(__VA_ARGS__);                             \
    DEBUG_OUT << "[" << __LINE__ << "] " << #__VA_ARGS__ << " = " << __debug_tap \
    << std::endl;                                                      \
  }()
template < class T >
inline void dump2D(T &d, size_t sizey, size_t sizex) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << "\t";
    for(size_t j = 0; j < sizex; j++)
      DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t");
    DEBUG_OUT << std::endl;
  }
}
template < class T >
inline void dump1D(T &d, size_t sizey) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " ");
  }
  DEBUG_OUT << std::endl;
}
template <
class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,
      class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >
      std::ostream &operator<<(std::ostream &os, const T &a) {
        os << "{";
        for(auto ite = begin(a); ite != end(a); ++ite)
          os << (ite == begin(a) ? "" : ", ") << *ite;
        os << "}";
        return os;
      }
#else
#define dump(...) (42)
#define dump2D(...) (42)
#define dump1D(...) (42)
template <
class T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,
      class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >
      std::ostream &operator<<(std::ostream &os, const T &a) {
        for(auto ite = begin(a); ite != end(a); ++ite)
          os << (ite == begin(a) ? "" : " ") << *ite;
        return os;
      }
#endif
// }}}

using X = vector<int>;

X inverse(X x) {
  X r(x.size());
  for(int i = 0; i < x.size(); i++) r[x[i]] = i;
  return r;
}

X op(X a, X b) {
  X r(a.size());
  for(int i = 0; i < a.size(); i++) r[i] = a[b[i]];
  return r;
}

X f(X a, X b) {
  X r(a.size());
  for(int i = 0; i < a.size(); i++) r[a[i]] = b[i];
  return r;
}

int n, k;

X getE() {
  X r(n);
  iota(begin(r), end(r), 0);
  return r;
}

X x[4];
int cycle[] = {1, 3, 2, 0};

// 実験しただけ…

X get(int start, int t) {
  int t4 = t / 4;
  auto a = getE();
  for(int i = 0; i < 4; i++) a = op(a, x[cycle[(start + i) % 4]]);
  auto r = getE();
  while(t4) {
    if(t4 & 1) r = op(r, a);
    a = op(a, a);
    t4 >>= 1;
  }
  t %= 4;
  for(int i = 0; i < t; i++) r = op(r, x[cycle[(start + i) % 4]]);
  return r;
}


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);

  cin >> n >> k;
  k--;
  X p(n), q(n);
  for(auto & e: p) cin >> e, e--;
  for(auto & e: q) cin >> e, e--;
  x[0] = p;
  x[1] = q;
  x[2] = inverse(q);
  x[3] = inverse(p);

  // assert(p == inverse(x[3]));
  // assert(q == inverse(x[2]));

  vector<vector<int>> v;
  v.push_back({0});
  v.push_back({1});
  for(int i = 0; i < 15; i++) {
    auto u = v[i];
    auto w = v[i+1];
    for(auto &e : u) e = 3 - e;
    while(u.size() && w.size() && u.back() + w.back() == 3) w.pop_back(), u.pop_back();
    reverse(u.begin(), u.end());
    w.insert(w.end(), u.begin(), u.end());
    v.push_back(w);
    // dump(i, v[i].size());
    // dump(v[i]);
  }

  auto r = getE();
  if(k <= 10) {
    for(int i = 0; i < v[k].size(); i++) r = op(r, x[v[k][i]]);
  } else {
    int c = 5 + 2 * ((k - 6) / 3);
    int len = 6 + 4 * ((k - 5) / 3);
    switch(k % 3) {
      case 0:
        len += 1;
        break;
      case 1:
        len += 3;
        break;
      case 2:
        c++;
        break;
    }
    assert(len >= c);
    auto a = get(0, c);
    auto b = inverse(get(0, len - c));
    r = op(a, b);
  }

  for(int i = 0; i < n; i++) cout << r[i] + 1 << " \n"[i == n - 1];

  return 0;
}



Measured memory_bytes: 5820