n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

dp = []*(n+1)
l = [-1]*(2*10**5+1)
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]
list = [-1]
while s != -1
  list << s
  s = dp[l[a[s]]+1]
end

t = list[k % list.length]
ans = []
exit if t == -1
t.upto(n-1) do |i|
  v = a[i]
  if x = ans.index(v)
    ans = ans[0,x]
  else
    ans << v
  end
end
#p dp
#p l
#p t
puts ans.join(" ")