n = gets.chomp.to_i
a=[]
b=[]
(n-1).times do
  aa, bb = gets.chomp.split.map(&:to_i)
  a.push aa
  b.push bb
end

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

(n-1).times do |i|
  used_colors = (colors[a[i]] + colors[b[i]]).uniq
  use = nil
  1.upto(saidai) do |num|
    if not used_colors.any?{|e| e == num}
      use = num
      break
    end
  end
  if use == nil
    saidai += 1
    use = saidai
  end

  colors[a[i]].push use
  colors[b[i]].push use
  ans.push use
end

puts saidai
puts ans



