import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; public class Main { static List> list; static int[] dp; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int q = Integer.parseInt(sa[1]); list = new ArrayList<>(n); for (int i = 0; i < n; i++) { list.add(new ArrayList<>()); } for (int i = 0; i < n - 1; i++) { sa = br.readLine().split(" "); int a = Integer.parseInt(sa[0]) - 1; int b = Integer.parseInt(sa[1]) - 1; list.get(a).add(b); list.get(b).add(a); } int[] p = new int[q]; int[] x = new int[q]; for (int i = 0; i < q; i++) { sa = br.readLine().split(" "); p[i] = Integer.parseInt(sa[0]) - 1; x[i] = Integer.parseInt(sa[1]); } br.close(); dp = new int[n]; dfs(0, -1); long ans = 0; PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < q; i++) { ans += (long) dp[p[i]] * x[i]; pw.println(ans); } pw.flush(); } static int dfs(int x, int p) { int ret = 1; for (int c : list.get(x)) { if (c != p) { ret += dfs(c, x); } } return dp[x] = ret; } }