n = gets.to_i

ab = []
f = Array.new(n+1){[]}
(n-1).times do |i|
    a, b = gets.split.map(&:to_i)
    f[a] << i
    f[b] << i
    ab << [a, b]
end

ans = Array.new(n-1)
que = [1]
pc = Array.new(n+1, 0)

while x = que.shift
    c = 1

    f[x].each do |i|
        next if ans[i]
        y = ab[i][0] == x ? ab[i][1] : ab[i][0]
        c += 1 if c == pc[x]

        ans[i] = c
        pc[y] = c
        que << y
        c += 1
    end
end

puts ans.max, ans