import sys sys.setrecursionlimit(10 ** 9) n,q=map(int,input().split()) g=[[] for i in range(n)] for i in range(n-1): a,b=map(int,input().split()) a-=1 b-=1 g[a].append(b) g[b].append(a) s=[0]*n def dfs(now,before): s[now]=1 for next in g[now]: if next==before: continue dfs(next,now) s[now]+=s[next] dfs(0,-1) ans=0 for _ in range(q): p,x=map(int,input().split()) p-=1 ans+=s[p]*x print(ans)