Imports System.Collections.Generic
Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim edge(0 To n - 1) As Long
    Dim vs(0 To n - 1) As Dictionary(Of Long, Long)
    Dim vsFor(0 To n - 1) As Dictionary(Of Long, Long)
    Dim visited(0 To n - 1) As Boolean
    For i As Long = 0 To n - 2
      edge(i) = 0
    Next 
    For i As Long = 0 To n - 1
      vs(i) = New Dictionary(Of Long, Long)
      vsFor(i) = New Dictionary(Of Long, Long)
      visited(i) = False
    Next
    For i As Long = 0 To n - 2
      Dim ab As Long() = Array.ConvertAll(Of String, Long)(Console.ReadLine().Split(" "), AddressOf Long.Parse)    
      edge(ab(0) - 1) += 1
      edge(ab(1) - 1) += 1
      vs(ab(0) - 1).Add(ab(1), 0)
      vs(ab(1) - 1).Add(ab(0), 0)
      vsFor(ab(0) - 1).Add(ab(1), 0)
      vsFor(ab(1) - 1).Add(ab(0), 0)
    Next
    Dim ans As Long = 0
    For i As Long = 0 To n - 1
      ans = Math.Max(ans, edge(i))
    Next
    Console.WriteLine(ans.ToString())
    For i As Long = 0 To n - 1
      visited(i) = True
      For Each k As Long In vsFor(i).Keys
        If Not visited(k - 1) Then
          For j As Long = 1 To ans
            If Not vs(i).ContainsValue(j) Then 
              vs(i)(k) = j
              Console.WriteLine(j.ToString())
              vs(k - 1)(i + 1) = j
              visited(k - 1) = True
              Exit For
            End If
          Next
        End If
      Next
    Next
  End Sub
End Class