let n = stdin.ReadLine() |> int
let ab = Array.init (n - 1) (fun _ -> stdin.ReadLine().Split() |> Array.map int)

let mutable array1 = Array.init (n + 1) (fun _ -> 0)

for i in 0..(n-2) do
 array1.[ab.[i].[0]] <- array1.[ab.[i].[0]] + 1
 array1.[ab.[i].[1]] <- array1.[ab.[i].[1]] + 1

let max = Array.max array1

max
|> stdout.WriteLine

let mutable array2 = Array.init (n + 1) (fun _ -> 1)

for i in 0..(n-2) do
 array2.[ab.[i].[0]] |> stdout.WriteLine
 let c = array2.[ab.[i].[0]]
 array2.[ab.[i].[0]] <- ((c % max) + 1)
 array2.[ab.[i].[1]] <- ((c % max) + 1)