import sys readline = sys.stdin.readline N,Q = map(int,readline().split()) G = [[] for i in range(N)] indegree = [0] * N for _ in range(N - 1): a,b = map(int,readline().split()) G[a - 1].append(b - 1) G[b - 1].append(a - 1) indegree[a - 1] += 1 indegree[b - 1] += 1 # 入り次数が1の頂点からスタートして、自分は部分木サイズ1 # それを次の親に対していく cnt = [1] * N starts = [] for i in range(1, N): if indegree[i] == 1: starts.append(i) dist_from_start = [0] * N stack = [[0, 0, -1]] while stack: v,d,p = stack.pop() dist_from_start[v] = d for child in G[v]: if child == p: continue stack.append([child, d + 1, v]) while starts: next_starts = [] for s in starts: indegree[s] -= 1 for child in G[s]: if dist_from_start[child] > dist_from_start[s]: continue cnt[child] += cnt[s] indegree[child] -= 1 if indegree[child] == 1 and child != 0: next_starts.append(child) starts = next_starts ans = 0 for _ in range(Q): p,x = map(int,readline().split()) ans += cnt[p - 1] * x print(ans)