n = gets.to_i
a = []
b = []
connect_vertex = Array.new(n+1,0)
(n-1).times do |i|
  a[i], b[i] = gets.chomp.split(" ").map(&:to_i)
  connect_vertex[a[i]] += 1
  connect_vertex[b[i]] += 1
end
max = connect_vertex.max
puts max
sorting_array = Array.new(n+1).map{Array.new}
(n-1).times do |i|
  for j in 1..max
    if !sorting_array[a[i]].include?(j) && !sorting_array[b[i]].include?(j)
      puts j
      sorting_array[a[i]].push(j)
      sorting_array[b[i]].push(j)
      break
    end
  end
end