import sys sys.setrecursionlimit(10**7) readline = sys.stdin.readline def dfs(s, p=-1): n = 1 for u in G[s]: if u == p: continue n += dfs(u, s) dp[s] = n return n N, Q = map(int, readline().split()) G = [[] for i in range(N)] for i in range(N - 1): A, B = map(int, readline().split()) A, B = A - 1, B - 1 G[A].append(B) G[B].append(A) dp = [0] * N dfs(0) ans = 0 for _ in range(Q): p, x = map(int, readline().split()) p -= 1 ans += dp[p] * x print(ans)