#n, m, k = gets.split.map(&:to_i)

n = gets.to_i

to = []
n.times do to << [] end

(n-1).times do |i|
    a, b = gets.split.map(&:to_i)
    a -= 1
    b -= 1
    to[a] << [b, i]
    to[b] << [a, i]
end

que = []
que << [0, -1]

ans = {}

vcolmax = 1
while que.size != 0
    xx = que.shift
    u = xx[0]
    col = xx[1]
    vcol = 1
    to[u].each do |x|
        v = x[0]
        idx = x[1]
        next if ans[idx] != nil
        vcol += 1 if vcol == col
        ans[idx] = vcol
        que << [v, vcol]
        vcolmax = [vcolmax, vcol].max
        vcol += 1
    end
end

puts vcolmax
ans.to_a.sort.each do |a|
    puts a[1]
end
