n, q = map(int, input().split()) to = [[] for _ in range(n)] for _ in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) dp = [0] * n def dfs(u, p=-1): dp[u] = 1 for v in to[u]: if v == p: continue dfs(v, u) dp[u] += dp[v] dfs(0) ans = 0 for _ in range(q): p, x = map(int, input().split()) ans += dp[p - 1] * x print(ans)