#include using namespace std; int n, q, a, b, p; long long x, m = 0; vector e[100001]; long long r[100001]; int dfs(int f, int k) { if (e[k].size() == 1) return r[k] = 1; int t = 0; for (int j : e[k]) { if (j != f) t += dfs(k, j); } return r[k] = t + 1; } int main() { cin >> n >> q; for (int i = 0; i < n - 1; i++) { cin >> a >> b; e[a].push_back(b); e[b].push_back(a); } dfs(-1, 1); for (int i = 0; i < q; i++) { cin >> p >> x; m += x * r[p]; cout << m << endl; } }