import sys input = sys.stdin.readline N, Q = map(int, input().split()) e = [[] for _ in range(N + 1)] for _ in range(N - 1): u, v = map(int, input().split()) e[u].append(v) e[v].append(u) s = [1] vis = [0] * (N + 1) parent = [0] * (N + 1) vis[1] = 1 order = [] while len(s): x = s.pop() order.append(x) for y in e[x]: if vis[y]: continue parent[y] = x vis[y] = 1 s.append(y) size = [1] * (N + 1) order.reverse() for y in order[: -1]: x = parent[y] size[x] += size[y] res = 0 for _ in range(Q): x, v = map(int, input().split()) res += size[x] * v print(res)