while true
    l = gets.to_i
    break if l == 0
    
    s = gets.split.map(&:to_i)
    idx = 0
    while true
        current = s
        s = current.map {|i| current.count(i)}
        break if current == s
        idx += 1
    end
    puts idx
    puts s.join(' ')
end
