n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
s = []
pos = {}
for i in 0...k do
  for j in 0...n do
    x = a[j]
    if !pos.include?(x)
      pos[x] = s.size
      s.push(x)
#      p "add", pos, s
    else
      p = pos[x]
      for k in p...s.size do
        pos.delete(s[k])
      end
      s.slice!(p, s.size - p)
#      p "del", pos, s
    end
  end
end
puts s.join(" ")
