n, q = map(int, input().split()) g = [[] for _ in range(n)] for _ in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) src = 0 st = [~ src, src] par = [None for _ in range(n)] dp = [0 for _ in range(n)] while len(st) > 0: cur = st.pop() if cur >= 0: for nxt in g[cur]: if nxt == par[cur]: continue par[nxt] = cur st.append(~ nxt) st.append(nxt) else: dp[~ cur] += 1 if not par[~ cur] is None: dp[par[~ cur]] += dp[~ cur] ans = 0 for _ in range(q): p, x = map(int, input().split()) p -= 1 ans += dp[p] * x print(ans)