N = gets.to_i

edges = Hash.new { |h, k| h[k] = [] }

list = []

(N - 1).times do
  a, b = gets.split.map(&:to_i) 

  list << [a, b]

  edges[a] << b
  edges[b] << a
end

root = 1

visited = Hash.new(false)
colors = Hash.new { |h, k| h[k] = {} }
cant_use = Hash.new { |h, k| h[k] = Hash.new(false) }

queue = [root]

until queue.empty?
  from = queue.shift

  next if visited[from]
  visited[from] = true

  c = 1

  edges[from].each do |to|
    next if visited[to]

    c += 1 while cant_use[from][c]

    colors[from][to] = c
    cant_use[to][c] = true
    c += 1
    queue << to
  end
end

ans = []
list.each do |a, b|
  ans << colors[a][b]
end

puts ans.max
puts ans
