N,Q = map(int,input().split()) def f(n): return int(n) - 1 ab = [list(map(f,input().split( ))) for _ in range(N-1)] import sys sys.setrecursionlimit(10**8) e = [[] for _ in range(N)] for i in range(N-1): a,b = ab[i] e[a].append(b) e[b].append(a) d = [0 for _ in range(N)] def dfs(n): d[n] += 1 for i in e[n]: if d[i] != 0: continue dfs(i) d[n] += d[i] dfs(0) sum = 0 for i in range(Q): p,x = map(int,input().split()) sum += d[p-1]*x print(sum)