#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) # _INPUT = """3 1 # 1 2 # 1 3 # 1 5 # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**10 def dfs(G, count, parent, p): v = 1 for p1 in G[p]: if p1 == parent: continue v += dfs(G, count, p, p1) count[p] = v return v N, Q = map(int, input().split()) G = [list() for _ in range(N)] for _ in range(N-1): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) count = [0] * N dfs(G, count, -1, 0) n = 0 for _ in range(Q): p, x = map(int, input().split()) p -= 1 n += count[p] * x print(n)