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

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