require 'pp'

n = gets.chomp!.to_i

tree = {}
tree_max = 0

(n-1).times do |i|
  a, b = gets.chomp!.split(" ").map(&:to_i)
  tree[a] ||= {}
  tree[b] ||= {}
  tree[a][b] = 0
  tree[b][a] = 0
  if tree[a].length > tree_max
    tree_max = tree[a].length
  end
  if tree[b].length > tree_max
    tree_max = tree[b].length
  end  
end

puts tree_max
ng = Array.new(n-1, 0)
1.upto(n-1) do |num|
  count = 0
  tree[num].each do |k, _|
    if tree[num][k] == 0
      count += 1
      if ng[num] == count
        count += 1
      end
      puts count
      ng[k] = count
      tree[num].delete(k)
      tree[k].delete(num)
    end
  end
end



