def fOA(a)
    return a.map {|i| a.count(i)}
end

while line=gets
    l=line.to_i
    break if l == 0
    s = gets.chomp.split(" ")
    idx = 0
    while true
        current = s
        s = fOA(s)
        if (current - s).empty?
            puts idx
            puts "#{s.join(' ')}"
            break
        end
        idx += 1
    end
end
