n = gets.to_s.to_i

g = Array.new(n){ [] }
(n-1).times do |i|
  a, b = gets.to_s.split.map{|t| t.to_i - 1 }
  g[a] << [b, i]
  g[b] << [a, i]
end

q = [0, -1, -1]

ans = Array.new(n-1)
while q[0]
  v, parent, parent_color = q.pop
  color = 0
  g[v].each do |(u, i)|
    next if u == parent
    # p [v, color] if i == 0
    color += 1
    color += 1 if color == parent_color
    # p [v, color] if i == 0
    ans[i] = color
    q << [u, v, color]
  end
end
# puts "ans"
puts ans.max, ans