#coding: euc-jp
class Main
  def self.main
    n, k = read
    p = read
    q = read
    r = [p, q]
    (k-2).times do |i1|
      p1 = i1 % 2; p2 = 1 - p1
      #p r
      nextp = n.times.map{|i2| r[p2][ r[p1].index(i2 + 1) ]}
      r[p1] = Marshal.load(Marshal.dump(nextp))
      if p == r[p2] && q == r[p1] then
        i = ((k / (i1+1)).floor * (i1+1))
        if i % 2 == 1 then
          p1, p2 = p2, p1
        end
        i1 = i - 1
      end
    end
    n.times do |i|
      print r[(k-1) % 2][i].to_s + ((i != n-1) ? ' ' : '')
    end
  end

  def self.read
    gets.chomp.split.map(&:to_i)
  end
end

Main.main
