require 'set'

n = gets.chomp.to_i

colors = Array.new(n+1) { Set.new()}
ansset = Set.new()
ans = []
saidai = 0

(n-1).times do |i|
  a, b = gets.chomp.split.map(&:to_i)

  use = nil
  unused_colors = ans.to_set - colors[a] - colors[b]
  use = unused_colors.to_a.sample
  if use == nil
    saidai += 1
    use = saidai
  end

  colors[a].add use
  colors[b].add use
  ans.push use
  ansset.add use
end

puts saidai
puts ans
