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