from collections import defaultdict from sys import setrecursionlimit def main(): setrecursionlimit(10 ** 6) n, q = map(int, input().split()) adj = defaultdict(list) for _ in range(n - 1): a, b = map(int, input().split()) a -= 1 b -= 1 adj[a].append(b) adj[b].append(a) visited = [0] * n # 0 = False subnodes = [0] * n def dfs(i): visited[i] = True res = 1 for j in adj[i]: if visited[j]: continue res += dfs(j) subnodes[i] = res return res dfs(0) ans = [] tmp = 0 for _ in range(q): p, x = map(int, input().split()) tmp += subnodes[p - 1] * x ans.append(tmp) print(*ans, sep='\n') if __name__ == "__main__": main()