import java.util.*; import java.util.concurrent.DelayQueue; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int Q = scan.nextInt(); Node[] nodes = new Node[N]; for (int i = 0; i < N; i++) { nodes[i] = new Node(); } int A, B; for (int i = 1; i < N; i++) { A = scan.nextInt() - 1; B = scan.nextInt() - 1; nodes[A].branch.add(B); } int now; long ans = 0; Queue nextNodes = new ArrayDeque<>(); for (int i = 0; i < Q; i++) { A = scan.nextInt() - 1; B = scan.nextInt(); nextNodes.add(A); while (!nextNodes.isEmpty()) { now = nextNodes.poll(); ans += B; for (int key : nodes[now].branch) { nextNodes.add(key); } } System.out.println(ans); } } } class Node { Set branch = new HashSet<>(); int cost = 0; }