#include using namespace std; using graph = vector>; void dfs(const graph &to, vector &children, int v, int p) { children.at(v)++; for (auto &&c : to.at(v)) { if (c == p) { continue; } dfs(to, children, c, v); children.at(v) += children.at(c); } } int main() { int n, q; cin >> n >> q; graph to(n); for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--; b--; to.at(a).push_back(b); to.at(b).push_back(a); } vector children(n); dfs(to, children, 0, -1); int64_t cost = 0; for (int i = 0; i < q; i++) { int p, x; cin >> p >> x; p--; cost += x * children.at(p); cout << cost << endl; } return 0; }