n = gets.to_i
edge = (n-1).times.map{gets.split.map(&:to_i)}
Vert = (0..n).map{[]}
Colors = []

edge.each.with_index{|(a,b),i|
  Vert[a] << [b,i]
  Vert[b] << [a,i]
}
def dfs a,parent,parent_color
  color = (parent_color==1)? 2 : 1
  Vert[a].each{|b,i|
    next if b == parent
    Colors[i] = color
    dfs b,a,color
    color += 1
    color += 1 if color == parent_color
  }
end
dfs 1,0,0
p Colors.max
puts Colors