MAX = 2*10**5+1
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

dp = []*(n+1)
l = [-1]*MAX
dp[n] = -1
(n-1).downto(0) do |i|
  v = a[i]
  if l[v] == -1
    dp[i] = i
  else
    dp[i] = dp[l[v]+1]
  end
  l[v] = i
end

s = dp[0]
period = [-1]
while s != -1
  period << s
  s = dp[l[a[s]]+1]
end

t = period[k % period.length]
ans = []
pos = [-1]*MAX

exit if t == -1

t.upto(n-1) do |i|
  v = a[i]
  if pos[v] != -1
    (ans.length-pos[v]).times do
      pos[ans[-1]] = -1
      ans.pop
    end
  else
    pos[v] = ans.length
    ans << v
  end
end

puts ans.join(" ")