import sys input = sys.stdin.readline sys.setrecursionlimit(10**8) N,Q = map(int,input().split()) AB = [tuple(map(int,input().split())) for i in range(N-1)] PX = [tuple(map(int,input().split())) for i in range(Q)] es = [[] for _ in range(N)] for a,b in AB: a,b = a-1,b-1 es[a].append(b) es[b].append(a) cs = [0] * N def dfs(v,p=-1): if len(es[v])==1: cs[v] = 2 if v==0 else 1 return cs[v] ret = 1 for to in es[v]: if to==p: continue ret += dfs(to,v) cs[v] = ret return ret dfs(0) ans = 0 for p,x in PX: p -= 1 ans += cs[p] * x print(ans)