#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int n; vector> g; vector sz; void dfs(int u, int pre) { sz[u] = 1; for (int v : g[u]) { if (v == pre) continue; dfs(v, u); sz[u] += sz[v]; } } int main() { fast_io(); int q; cin >> n >> q; g.resize(n); sz.resize(n); for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--, b--; g[a].push_back(b); g[b].push_back(a); } dfs(0, -1); long long ans = 0; for (; q--;) { int p; long long x; cin >> p >> x; ans += x * sz[p - 1]; cout << ans << "\n"; } }