#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; typedef unsigned long long ull; using P=pair; const int INF=1001001001; const int mod=998244353; vectorG[100005]; int cnt; ll t[100005],have[100005]; void dfs(int i,int pre=-1){ t[i]=cnt++; for(int u:G[i]){ if(u!=pre){ dfs(u,i); } } have[i]=cnt-t[i]; } void solve(){ 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 tot=0; rep(i,q){ int p,x; cin>>p>>x; p--; tot+=have[p]*x; cout<