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