N = gets.chomp.to_i
counter = Array.new(N,0)
input = []
(N - 1).times do
  line = gets.chomp.split(" ").map(&:to_i)
  counter[line[0] - 1] += 1
  counter[line[1] - 1] += 1
  input << line
end

K = counter.max
puts K

input.each do |line|
  color = [counter[line[0] - 1]  , counter[line[1] - 1]].max
  puts color
  counter[line[0] - 1] -= 1
  counter[line[1] - 1] -= 1
end