n = gets.to_i
road = Array.new(n+1){Array.new(n+1,true)}
color = [1]
ans = []

(n-1).times do
    a,b = gets.split.map(&:to_i)
    c = true

    color.each do |e|
        if road[a][e] && road[b][e]
            road[a][e] = road[b][e] = false
            ans << e
            c = false
            break
        end
    end

    if c
        x = color.last + 1
        road[a][x] = road[b][x] = false
        color << x
        ans << x
    end
end

puts color.length
puts ans