
s = []

(n,k) = gets.split.map{|x| x.to_i}
a = gets.split.map{|x| x.to_i}

large = 99999999

cand = [[]]

ex = Array.new(200000,large)

s = []
front = 0
while true
  i = 0
  while i < a.size
    v = a[i]
    if ex[v] < front
      new_front = ex[v]
      j = front - 1
      while j >= new_front
        ex[s[j]] = large
        j -= 1
      end
      front = new_front
    else
      s[front] = v
      ex[v] = front
      front += 1
    end
    #puts "#{i} #{v} #{s[0,front].join(" ")}"
    i += 1
  end
  if front == 0
    break
  end
  #puts "#{s.join(" ")} #{front}"
  cand << s[0,front].dup
end

#p cand

m = k % cand.size
puts cand[m].join(" ")

