n,q=map(int,input().split()) g=[[] for _ in range(n)] for _ in range(n-1): a,b=map(lambda x: int(x)-1,input().split()) g[a].append(b) g[b].append(a) ch=[0]*n def rec(v, p= -1): ret = 1 for nv in g[v]: if nv==p:continue ret += rec(nv, v) ch[v] = ret return ret rec(0) ans=0 for _ in range(q): p,x=map(int,input().split()) p -= 1 ans += ch[p] * x print(ans)