until (n = gets.to_i).zero?
  arr, k = gets.split.map(&:to_i), 0
  
  loop do
    k += 1
    tmp = n.times.map{ |i| arr.count(arr[i]) }
    arr == tmp ? break : arr = tmp
  end
  
  puts k - 1, arr.join(" ")
end