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

(n-1).times do
    a,b = gets.split.map(&:to_i)
    n.times do |i|
        if road[a][i] && road[b][i]
            road[a][i] = road[b][i] = false
            ans << i+1
            break
        end
    end
end

puts ans.max
puts ans