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

edges = Hash.new

A.uniq.each do |a|
  n = indices[a].size

  n.times do |i|
    idx = indices[a][i]

    edges[idx] = indices[a][(i + 1) % n]
  end
end

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

# p indices

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

  loop_cnt = 0

  loop {
    a = A[cur]

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

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

    if to.nil?
      case status
      when :on
        status = :off

        if indices[a].size <= 1
          cur = (cur + 1) % N
        else
          cur = indices[a].first
        end

        break if cur == 0
      when :off
        status = :on
        break
      end
    else
      case status
      when :on
        status = :off
        cur = (cur + 1) % N
        break if cur == 0
      when :off
        status = :off
        cur = (to + 1) % N
        break if cur == 0
      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 edges
# p indices
path.pop
pl = path.size
# p [:path, path]

if K == 1
  puts simulate([]).join(' ')
elsif pl == 0
  puts ''
else
  v = ((K - 2) % pl)
  idx = path[v]
  a = A[idx]
  # p [:k, k]
  # p simulate([k])
  res = simulate([a])
  puts res.join(' ')
end
