import sys INF = float('inf') #10**20,2**63,float('inf') MOD = 10**9 + 7 MOD2 = 998244353 #from collections import defaultdict def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LC(): return list(input()) def IC(): return [int(c) for c in input()] def MI(): return map(int, sys.stdin.readline().split()) N,Q = MI() Graph = [[] for _ in range(N+1)] for _ in range(N-1): A,B = MI() Graph[A].append(B) Graph[B].append(A) sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!! DP = [0]*(N+1) Seen = [False]*(N+1) def dfs(now): Seen[now] = True DP[now] = 1 #→nowで初めてたどり着いたときに行う処理はここで for next in Graph[now]: if not Seen[next]: dfs(next) DP[now] += DP[next] # next→now:戻る時に行う処理はここで # now←で全ての探索可ノードを終えたときに行う処理はここで dfs(1)#根は1 #print(DP) Ans = 0 for _ in range(Q): P,X = MI() Ans += DP[P]*X print(Ans)