import sys sys.setrecursionlimit(10 ** 6) N,Q = map(int,input().split()) G = [[] for i in range(N)] for _ in range(N - 1): a,b = map(int,input().split()) G[a - 1].append(b - 1) G[b - 1].append(a - 1) cnt = [0] * N # 自分を含む子の数 def dfs(v, p): c = 1 for child in G[v]: if child == p: continue c += dfs(child, v) cnt[v] = c return c dfs(0, -1) ans = 0 for _ in range(Q): p,x = map(int,input().split()) ans += cnt[p - 1] * x print(ans)