#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=Int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } class EulerTourForVertex{ private: vector<Int> ls,rs; Int pos; void dfs(Int v,Int p){ ls[v]=pos++; for(Int u:G[v]) if(u!=p) dfs(u,v); rs[v]=pos; } public: vector< vector<Int> > G; EulerTourForVertex(Int n):ls(n),rs(n),G(n){} void add_edge(Int u,Int v){ G[u].emplace_back(v); G[v].emplace_back(u); } void build(Int r=0){ pos=0; dfs(r,-1); } Int idx(Int v){return ls[v];} template<typename F> void exec(Int v,F f){ f(ls[v],rs[v]); } }; //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); Int n,q; cin>>n>>q; EulerTourForVertex G(n); for(Int i=1;i<n;i++){ Int a,b; cin>>a>>b; a--;b--; G.add_edge(a,b); } G.build(0); Int ans=0; for(Int i=0;i<q;i++){ Int p,x; cin>>p>>x; p--; G.exec(p,[&](Int l,Int r){ans+=(r-l)*x;}); cout<<ans<<newl; } return 0; }