local mfl = math.floor

local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local n, k = io.read("*n", "*n")
local a = {}
local poslist = {}
for i = 1, n do
  a[i] = io.read("*n")
  if not poslist[a[i]] then
    poslist[a[i]] = {}
  end
  table.insert(poslist[a[i]], i)
end

local rep = 1
local curpos = 1
while true do
  local pary = poslist[a[curpos]]
  local nxt = lower_bound(pary, curpos + 1)
  local np = 0
  if #pary < nxt then
    rep = rep + 1
    curpos = pary[1] + 1
  else
    curpos = pary[nxt] + 1
  end
  if n < curpos then
    break
  end
end
k = k % rep
if k == 0 then
  print("")
else
  rep = 1
  curpos = 1
  while true do
    if k == rep then break end
    local pary = poslist[a[curpos]]
    local nxt = lower_bound(pary, curpos + 1)
    local np = 0
    if #pary < nxt then
      rep = rep + 1
      curpos = pary[1] + 1
    else
      curpos = pary[nxt] + 1
    end
  end
  local ans = {}
  local ansbox = {}
  local cursize = 0
  for i = curpos, n do
    if ansbox[a[i]] and ansbox[a[i]] <= cursize then
      cursize = ansbox[a[i]] - 1
      ansbox[a[i]] = nil
    else
      cursize = cursize + 1
      ansbox[a[i]] = cursize
      ans[cursize] = a[i]
    end
  end
  for i = 1, cursize do
    io.write(ans[i])
    io.write(i == cursize and "\n" or " ")
  end
end
