N,K=gets.chomp.split(" ").map(&:to_i)
lst=gets.chomp.split(" ").map(&:to_i)
def sunuke(ls,num)
  if ls.include?(num)
    if ls.index(num)==0
      return []
    else
      return ls[0,ls.index(num)]
    end
  else
    return ls.push(num)
  end
end
$array=[]
i=0
while(i<K)
  j=0
  while(j<N)
  $array=sunuke($array,lst[j])
  j=j+1
  end
  i=i+1
end
puts $array.join(' ')
   
