import sys sys.setrecursionlimit(10**6) N,Q = map(int,input().split()) lsg = [[] for i in range(N)] for i in range(N-1): a,b = map(int,input().split()) a -= 1 b -= 1 lsg[a].append(b) lsg[b].append(a) lsq = [tuple(map(int,input().split())) for i in range(Q)] lsc = [1]*(N) def dfs(k,p): for j in lsg[k]: if j == p: continue lsc[k] += dfs(j,k) return lsc[k] dfs(0,-1) ans = 0 for i in range(Q): p,x = lsq[i] p -= 1 ans += lsc[p]*x print(ans)