n = gets.to_i
ab = (n-1).times.map{gets.split.map(&:to_i)}

color_cnt = Array.new(n, 0)
ab.each do |a, b|
  color_cnt[a-1] += 1
  color_cnt[b-1] += 1
end

puts color_cnt.max

path = Array.new(n, 0)
ab.each do |a, b|
  path[a - 1] += 1
  path[b - 1] += 1
  puts [path[a - 1], path[b - 1]].max
end


