output_description: Print N integers, with spaces in between. The i-th integer (1 \leq i \leq N)
  should be the i-th element in a_K.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      p_1 ... p_N
      q_1 ... q_N
attempt: from operator import itemgetter
  
  
  def get_identity():
      return list(range(1, n + 1))
  
  
  def composition(ppp, qqq):
      return [ppp[q - 1] for q in qqq]
  
  
  def reverse_composition(ppp, qqq):
      return [ppp[i] for i, q in sorted(enumerate(qqq), key=itemgetter(1))]
  
  
  def solve(k, ppp, qqq):
      qp = reverse_composition(qqq, ppp)
      qpq = reverse_composition(qp, qqq)
      qpqp = composition(qpq, ppp)
  
      l, m = divmod(k - 1, 6)
      res = get_identity()
      tmp = qpqp
      while l:
          if l % 2 == 1:
              res = composition(res, tmp)
          tmp = composition(tmp, tmp)
          l >>= 1
  
      m = (k - 1) % 6
      if m == 0:
          base = ppp
      elif m == 1:
          base = qqq
      elif m == 2:
          base = reverse_composition(qqq, ppp)
      elif m == 3:
          res = composition(res, qqq)
          base = reverse_composition(get_identity(), ppp)
      elif m == 4:
          res = composition(res, qqq)
          res = reverse_composition(res, ppp)
          base = reverse_composition(get_identity(), qqq)
      elif m == 5:
          res = composition(res, qqq)
          res = reverse_composition(res, ppp)
          base = reverse_composition(get_identity(), qqq)
          base = composition(base, ppp)
      else:
          raise NotImplementedError
  
      ans = composition(res, base)
      ans = reverse_composition(ans, res)
      return ans
  
  
  n, k = map(int, input().split())
  ppp = list(map(int, input().split()))
  qqq = list(map(int, input().split()))
  print(*solve(k, ppp, qqq))
  
problem_description: Statement
  
  For two permutations p and q of the integers from 1 through N, let f(p,q) be
  the permutation that satisfies the following:
  
    * The p_i-th element (1 \leq i \leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q.
  
  You are given two permutations p and q of the integers from 1 through N. We
  will now define a sequence {a_n} of permutations of the integers from 1
  through N, as follows:
  
    * a_1=p, a_2=q
    * a_{n+2}=f(a_n,a_{n+1}) ( n \geq 1 )
  
  Given a positive integer K, find a_K.
samples: [{"input": "3 3\n    1 2 3\n    3 2 1", "output": "3 2 1\n    \n\nSince a_3=f(p,q), we just need to find f(p,q). We have p_i=i here, so\nf(p,q)=q.\n\n* * *"}, {"input": "5 5\n    4 5 1 2 3\n    3 2 1 5 4", "output": "4 3 2 1 5\n    \n\n* * *"}, {"input": "10 1000000000\n    7 10 6 5 4 2 9 1 3 8\n    4 1 9 2 3 7 8 10 6 5", "output": "7 9 4 8 2 5 1 6 10 3"}]