#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair vector G[100005]; int c[100000]; void dfs(int v, int p = -1) { for (int nv : G[v]) { if (nv == p) continue; dfs(nv, v); c[v]++; c[v]+=c[nv]; } } int main() { int n, q; cin >> n >> q; rep(i,n-1) { int a, b; cin >> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); } dfs(0); ll ans = 0; rep(qi,q) { int p; ll x; cin >> p >> x; p--; ans += x*(c[p]+1); cout << ans << endl; } cout << endl; }