import sys sys.setrecursionlimit(10**9) N,Q=map(int,input().split()) G=[[] for _ in range(N)] for i in range(N-1): a,b=map(lambda x:int(x)-1,input().split()) G[a].append(b) G[b].append(a) seen=[False]*N subtree_size=[1]*N def dfs(G,v,p=-1): seen[v]=True for nextv in G[v]: if nextv!=p: dfs(G,nextv,v) for c in G[v]: if c!=p: subtree_size[v]+=subtree_size[c] dfs(G,0) ans=0 for i in range(Q): p,x=map(int,input().split()) ans+=x*subtree_size[p-1] print(ans)