from collections import * from itertools import * from functools import * from heapq import * import sys,math # input = sys.stdin.readline sys.setrecursionlimit(200000) N,Q = map(int,input().split()) e = [[] for _ in range(N)] for i in range(N-1): a,b = map(int,input().split()) a -= 1 b -= 1 e[a].append(b) e[b].append(a) dist = [-1]*N def dfs(x): if(x!=0): if len(e[x]) == 1: return for ix in e[x]: if dist[ix] == -1: dist[ix] = dist[x] + 1 dfs(ix) return dist[0] = 0 dfs(0) flg = [-1]*N def dfs_v2(x): if(x!=0): if len(e[x]) == 1: flg[x] = 1 return 1 if flg[x] != -1: return flg[x] tmp = 1 for ix in e[x]: if dist[ix] > dist[x]: tmp += dfs_v2(ix) flg[x] = tmp return tmp dfs_v2(0) S = 0 for _ in range(Q): p,x = map(int,input().split()) p -= 1 S += x*flg[p] print(S) # print(flg)