import sys sys.setrecursionlimit(10**5) n,q=map(int,input().split()) g=[[] for _ in range(n)] for _ in range(n-1): a,b=map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) subnode=[[] for _ in range(n)] visit=[False]*n def f(start): visit[start]=True num=1 for i in g[start]: num+=f(i) subnode[start]=num return num f(0) ans=0 for _ in range(q): p,x=map(int,input().split()) ans+=subnode[p-1]*x print(ans)