output_description: Print the number of possible values of the sum, modulo (10^9+7).
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
attempt: # 初期入力
  import numpy as np
  
  N, Q = (int(x) for x in input().split())
  aa = 0
  bb = 0
  a = [0]
  b = [0]
  a_set = set()
  ki_kouzou = np.zeros((N + 1, 1), dtype=np.int32)
  ki_kouzou_dic = {i: set() for i in range(1, N + 1)}
  
  # 木の構造を入力
  for i in range(1, N):  # 直接つながっているところ。
      aa, bb = (int(x) for x in input().split())
      if bb in a_set:  # 親子判定 頂点3⇒頂点2もありうる
          # np.append(ki_kouzou[bb,:],aa,axis=1)
          a_set.add(aa)
          ki_kouzou_dic[bb].add(aa)
      else:
          # np.append(ki_kouzou[aa,:],bb,axis=1)
          # ki_kouzou[aa].append(bb)
          ki_kouzou_dic[aa].add(bb)
          a_set.add(bb)
      a.append(aa)
      b.append(bb)
  
  
  # 間接的に繋がっているところ
  kansetu = {i: set() for i in range(1, N + 1)}
  for ki_key in range(1, N + 1):
      for v_v in ki_kouzou_dic[ki_key]:
          if v_v in ki_kouzou_dic.keys():
              kansetu[ki_key] = kansetu[ki_key] | ki_kouzou_dic[v_v]
  
  for i in range(1, N + 1):
      ki_kouzou_dic[i] = ki_kouzou_dic[i] | kansetu[i]  # 直接 ＋ 間接
      ki_kouzou_dic[i].add(i)  # 各頂点自身はは必ずポイント加算あり
  
  
  # ポイント入力-計算
  point = {i: 0 for i in range(1, N + 1)}
  pp = 0
  xx = 0
  for _ in range(Q):
      pp, xx = (int(x) for x in input().split())
      for i in ki_kouzou_dic[pp]:
          point[i] += xx
  
  print(*point.values())
  
problem_description: Statement
  
  We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.
  
  We will choose K or more of these integers. Find the number of possible values
  of the sum of the chosen numbers, modulo (10^9+7).
samples: [{"input": "3 2", "output": "10\n    \n\nThe sum can take 10 values, as follows:\n\n  * (10^{100})+(10^{100}+1)=2\\times 10^{100}+1\n  * (10^{100})+(10^{100}+2)=2\\times 10^{100}+2\n  * (10^{100})+(10^{100}+3)=(10^{100}+1)+(10^{100}+2)=2\\times 10^{100}+3\n  * (10^{100}+1)+(10^{100}+3)=2\\times 10^{100}+4\n  * (10^{100}+2)+(10^{100}+3)=2\\times 10^{100}+5\n  * (10^{100})+(10^{100}+1)+(10^{100}+2)=3\\times 10^{100}+3\n  * (10^{100})+(10^{100}+1)+(10^{100}+3)=3\\times 10^{100}+4\n  * (10^{100})+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+5\n  * (10^{100}+1)+(10^{100}+2)+(10^{100}+3)=3\\times 10^{100}+6\n  * (10^{100})+(10^{100}+1)+(10^{100}+2)+(10^{100}+3)=4\\times 10^{100}+6\n\n* * *"}, {"input": "200000 200001", "output": "1\n    \n\nWe must choose all of the integers, so the sum can take just 1 value.\n\n* * *"}, {"input": "141421 35623", "output": "220280457"}]