#include using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define INF ((1LL<<62)-(1LL<<31)) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() typedef long long ll; typedef pair pl; typedef tuple tupl; int main() { int n,q; cin >> n >> q; vector> G(n,vector ()); rep(i,n-1) { int a,b; cin >> a >> b; a--; b--; G[a].push_back(b); } ll sum=0; rep(i,q) { ll p,x; cin >> p >> x; p--; queue q; q.push(p); while(!q.empty()) { int v=q.front(); q.pop(); sum+=x; for(auto nv:G[v]) q.push(nv); } cout << sum << endl; } return 0; }