import pypyjit pypyjit.set_param('max_unroll_recursion=-1') n,q = map(int,input().split()) edge = [[] for _ in range(n)] for _ in range(n-1): a,b = map(int,input().split()) edge[a-1].append(b-1) edge[b-1].append(a-1) cnt = [0]*n def dfs(x,p): ret = 1 for c in edge[x]: if c == p: continue ret += dfs(c,x) cnt[x] += ret return ret dfs(0,-1) ans = 0 for _ in range(q): p,x = map(int,input().split()) ans += cnt[p-1]*x print(ans)