inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift() * 1
b = {}
for (i=0; i<N; i++) {
    b[i] = {n: [], b: [], u: {}}
}
for (i=0; i<N-1; i++) {
    l = inp[i].split(' ')
    j = l[0] * 1 - 1
    k = l[1] * 1 - 1
    b[j].n.push({ n: k, i: i })
    b[k].b.push({ b: j, i: i })
}
max = 0
a = []
for (i=0; i<N; i++) {
    if (max < b[i].n.length + b[i].b.length) {
        max = b[i].n.length + b[i].b.length
    }
}
for (i=0; i<N; i++) {
    for(j=0; j < b[i].n.length; j++) {
        o = b[i].n[j]
        for (k = 1; k < max; k++) {
            if (!b[i].u[k]) {
                break;
            }
        }
        o.c = k
        b[i].u[o.c] = 1
        b[o.n].u[o.c] = 1
        a[o.i] = o.c
    }
}
console.log(max)
console.log(a.join("\n"))