output_description: Print the number of subsequences that satisfy the condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 A_2 \cdots A_N
attempt: # 標準入力からKを求めるまで
  N = int(input())
  node = [0] * N
  AB = []
  for i in range(N - 1):
      ab = list(map(int, input().split()))
      node[ab[0] - 1] += 1
      node[ab[1] - 1] += 1
      AB.append(ab)
  K = max(node)
  print(K)
  
  # 各辺の色を求めていく
  color = [[i for i in range(1, K + 1)] for i in range(N)]
  for i in range(N - 1):
      now = list(set(color[AB[i][0] - 1]) & set(color[AB[i][1] - 1]))
      tmp = now[0]
      color[AB[i][0] - 1].remove(tmp)
      color[AB[i][1] - 1].remove(tmp)
      print(tmp)
  
problem_description: Statement
  
  Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
  positive integer K.
  
  Find the number of non-empty contiguous subsequences in A such that the
  remainder when dividing the sum of its elements by K is equal to the number of
  its elements. We consider two subsequences different if they are taken from
  different positions, even if they are equal sequences.
samples: [{"input": "5 4\n    1 4 2 3 5", "output": "4\n    \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n    4 2 4 2 4 2 4 2", "output": "7\n    \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n    14 15 92 65 35 89 79 32 38 46", "output": "8"}]