#include using namespace std; using Int = long long; const char newl = '\n'; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout< vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } class EulerTourForVertex{ private: vector 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 > 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 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>a>>b; a--;b--; G.add_edge(a,b); } G.build(0); Int ans=0; for(Int i=0;i>p>>x; p--; G.exec(p,[&](Int l,Int r){ans+=(r-l)*x;}); cout<