def main(): N, Q = map(int, input().split()) tree = [set() for _ in range(N)] for _ in range(N-1): a, b = map(lambda n: int(n)-1, input().split()) tree[a].add(b) tree[b].add(a) tree_size = [-1] * N stack = [(0, -1, 0)] while stack: cur, par, dir = stack.pop() match dir: case 1: tree_size[cur] = 1 for n in tree[cur]: if n == par: continue tree_size[cur] += tree_size[n] case 0: next_stack = [] for n in tree[cur]: if n == par: continue next_stack.append((n, cur, 0)) stack.append((cur, par, 1)) stack.extend(next_stack) case _: raise ValueError ans = 0 for _ in range(Q): p, x = map(int, input().split()) ans += tree_size[p-1] * x print(ans) if __name__ == "__main__": main()