import sys sys.setrecursionlimit(100000+100) N,Q = map(int,input().split()) G = {i:[] for i in range(1,N+1)} for _ in range(N-1): a,b = map(int,input().split()) G[a].append(b) G[b].append(a) C = [0]*(N+1) C0 = [[0,0] for _ in range(N+1)] C0[1][0] = 1 val = 2 def dfs(i,p): global val for j in G[i]: if j==p:continue C0[j][0] = val val += 1 dfs(j,i) C0[i][1] = val val += 1 dfs(1,0) for i in range(1,N+1): C[i] = (C0[i][1]-C0[i][0])//2 ans = 0 for _ in range(Q): p,x = map(int,input().split()) ans += (C[p]+1)*x print(ans)