N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

indices = Hash.new { |h, k| h[k] = [] }

A.each_with_index do |a, idx|
  indices[a] << idx
end

node = [-1, :off]
path = []
visited = Hash.new(false)

# p indices

while !visited[node]
  visited[node] = true
  cur, status = node

  if cur == -1
    cur = 0
  end

  loop_cnt = 0

  loop {
    a = A[cur]

    if loop_cnt == 0 && status == :on
      if indices[a].size <= 1
        to = nil
      else
        cur = indices[a].first
        to = indices[a].bsearch { |x| x > cur }
      end
    else
      to = indices[a].bsearch { |x| x > cur }
    end

    # p [:a, a, :cur, cur, :to, to, :status, status]

    case status
    when :on
      status = :off
      cur = (cur + 1) % N

      if cur == 0
        cur = -1
        break
      end
    when :off
      status = :on

      if to.nil?
        break
      else
        cur = to
      end
    end

    loop_cnt += 1
  }

  node = [cur, status]
  # p [:node, node]
  path << node[0]
end

def simulate(init)
  counter = Hash.new(0)

  init.each do |a|
    counter[a] += 1
  end

  res = init.dup

  A.each do |a|
    if counter[a] > 0
      while counter[a] > 0
        v = res.pop
        counter[v] -= 1
      end
    else
      counter[a] += 1
      res << a
    end
  end

  res
end

# p indices
path.pop
path.unshift(-1)
pl = path.size
# p [:path, path]
# p [:path, path.map { |idx| A[idx] }]

res = []
10.times do |i|
  # res = simulate(res)
  # p [:i, i + 1, res]
end

if K == 1
  puts simulate([]).join(' ')
elsif pl == 0
  puts ''
else
  v = ((K - 1) % pl)
  idx = path[v]

  ft = if idx == -1
         []
       else
         [A[idx]]
       end
  # p [:k, k]
  # p simulate([k])

  # p [:ft, ft]
  res = simulate(ft)
  puts res.join(' ')
end
