n = gets.chomp.to_i
edge = Array.new(n+1){Array.new}
anshash = {}
(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  edge[a].push b
  edge[b].push a
  a,b=b,a if a>b
  anshash[[a,b]] = -1
end

q = [[1, -1]]
(n-1).times do |i|
  vol, used_color = q.shift
  color = 0
  edge[vol].each do |v|
    a,b = [[vol,v].min, [vol,v].max]
    next if anshash[[a,b]] > 0
    color += 1
    color += 1 if color == used_color
    q.push [v, color]
    anshash[[a,b]] = color
  end
end

puts anshash.values.max
anshash.each do |k, v|
  puts v
end