import java.util.*; 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; int tmp; for (int i = 1; i < N; i++) { A = scan.nextInt() - 1; B = scan.nextInt() - 1; nodes[A].chiledNum++; tmp = A; while (nodes[tmp].root != -1) { tmp = nodes[tmp].root; nodes[tmp].chiledNum++; } nodes[B].root = A; } long ans = 0; for (int i = 0; i < Q; i++) { A = scan.nextInt() - 1; B = scan.nextInt(); ans += B * nodes[A].chiledNum; System.out.println(ans); } } } class Node { int root = -1; int chiledNum = 1; }