typedef long long ll; typedef long double ld; #include using namespace std; #define int long long signed main(){ ll n,q; std::cin >> n>>q; vector> edges(n); for (int i = 0; i < n-1; i++) { ll a,b; std::cin >> a>>b; a--;b--; edges[a].push_back(b); edges[b].push_back(a); } vector size(n); function dfs = [&](ll now, ll par){ ll sum = 1; for (auto e : edges[now]) { if(e==par)continue; sum += dfs(e, now); } return size[now] = sum; }; dfs(0,-1); ll ans = 0; for (int i = 0; i < q; i++) { ll p,x; std::cin >> p>>x; p--; ans += x*size[p]; std::cout << ans << std::endl; } }