output_description: Print N lines.
  
  The first line should contain K, the number of colors used.
  
  The (i+1)-th line (1 \le i \le N-1) should contain c_i, the integer
  representing the color of the i-th edge, where 1 \le c_i \le K must hold.
  
  If there are multiple colorings with the minimum number of colors that satisfy
  the condition, printing any of them will be accepted.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_1 b_1
      a_2 b_2
      \vdots
      a_{N-1} b_{N-1}
attempt: N = int(input())
  mat = [list(map(int, input().split())) for i in range(N - 1)]
  dic = dict(zip(range(1, N + 1), [0] * N))
  for i in range(N - 1):
      for j in range(2):
          dic[mat[i][j]] += 1
  K = max(dic.values())
  index = max(dic.items(), key=lambda x: x[1])[0]
  save = [[] for i in range(N)]
  tmp = [0] * (N - 1)
  num = 1
  for i in range(N - 1):
      if index in mat[i]:
          tmp[i] = num
          save[mat[i][0] - 1].append(num)
          save[mat[i][1] - 1].append(num)
          num += 1
  if 0 not in tmp:
      print(K)
      for i in range(len(tmp)):
          print(tmp[i])
  else:
      for i in range(len(tmp)):
          if tmp[i] == 0:
              for j in range(1, K + 1):
                  if j not in save[mat[i][0] - 1] and j not in save[mat[i][1] - 1]:
                      tmp[i] = j
                      save[mat[i][0] - 1].append(j)
                      save[mat[i][1] - 1].append(j)
      print(K)
      for k in range(len(tmp)):
          print(tmp[i])
  
problem_description: Statement
  
  Given is a tree G with N vertices. The vertices are numbered 1 through N, and
  the i-th edge connects Vertex a_i and Vertex b_i.
  
  Consider painting the edges in G with some number of colors. We want to paint
  them so that, for each vertex, the colors of the edges incident to that vertex
  are all different.
  
  Among the colorings satisfying the condition above, construct one that uses
  the minimum number of colors.
samples: [{"input": "3\n    1 2\n    2 3", "output": "2\n    1\n    2\n    \n\n* * *"}, {"input": "8\n    1 2\n    2 3\n    2 4\n    2 5\n    4 7\n    5 6\n    6 8", "output": "4\n    1\n    2\n    3\n    4\n    1\n    1\n    2\n    \n\n* * *"}, {"input": "6\n    1 2\n    1 3\n    1 4\n    1 5\n    1 6", "output": "5\n    1\n    2\n    3\n    4\n    5"}]