import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, q = map(int, input().split()) g = [[] for i in range(n)] for i in range(n-1): a, b = map(int, input().split()) a, b = a-1, b-1 g[a].append(b) g[b].append(a) s = [] order = [] par = [-1]*n s.append(0) while s: v = s.pop() order.append(v) for u in g[v]: if par[v] == u: continue par[u] = v s.append(u) order.reverse() C = [1]*n for v in order: if par[v] != -1: C[par[v]] += C[v] ans = 0 for i in range(q): p, x = map(int, input().split()) p -= 1 ans += C[p]*x print(ans)