N = gets.to_i
A,B = (N-1).times.map{gets.split.map(&:to_i)}.transpose
C=Array.new(N-1)
list=Array.new(N+1).map{Array.new}
for i in 0..N-2
  for j in 1..N-2
    if list[A[i]].include?(j)
      next
    end
    if list[B[i]].include?(j)
      next
    end
    list[A[i]].push(j)
    list[B[i]].push(j)
    C[i] = j
    break
  end
end
puts C.max,C