#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>s; vector > G(n); for(Int i=1;i>x>>y; x--;y--; G[x].emplace_back(y); G[y].emplace_back(x); } vector w(n,0),ww(n,0); { function dfs= [&](Int v,Int p){ w[v]=s[v]=='w'; for(Int u:G[v]){ if(u==p) continue; dfs(u,v); w[v]+=w[u]; ww[v]+=ww[u]; if(s[v]=='w') ww[v]+=w[u]; } }; dfs(0,-1); } Int ans=0,wa=0; for(Int i=0;i dfs= [&](Int v,Int p,Int x){ //cout<