def dfs(x,p): cnt=1 for i in g[x]: if i!=p: cnt+=dfs(i,x) ans[x]=cnt return cnt n,q=map(int,input().split()) g=[[] for i in range(n+1)] for i in range(n-1): a,b=map(int,input().split()) g[a].append(b) g[b].append(a) ans=[0]*(n+1) dfs(1,-1) a=0 for i in range(q): p,x=map(int,input().split()) a+=ans[p]*x print(a)