N = gets.to_i
B = []
(N - 1).times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  B << [a, b, 0]
}

C = Array.new(N + 1, 0)
B.each{|b|
  C[b[0]] += 1
  C[b[1]] += 1
}

def color(i, m)
  btmp = B.select{|b| b[0] == i || b[1] == i}
  (1..m).each{|c|
    if btmp.select{|b| b[2] == c}.size == 0 then
      btmp.find{|b| b[2] == 0}[2] = c
    end
  }
end
def color2(i, m)
  btmp = B.select{|b| b[0] == i || b[1] == i}
  (1..m).each{|c|
    if btmp.select{|b| b[2] == c}.size == 0 then
      if btmp.select{|b| b[2] == 0}.size > 0 then
        btmp.find{|b| b[2] == 0}[2] = c
      end
    end
  }
end

cm = C.max
(1..N).each{|i|
  color(i, cm) if C[i] == cm
}
(1..N).each{|i|
  color2(i, C[i]) if C[i] < cm
}

puts C.max
B.each{|b| puts b[2]}
