#include using namespace std; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a struct FixPoint : F{ FixPoint(F&& f):F(forward(f)){} template decltype(auto) operator()(Args&&... args) const{ return F::operator()(*this,forward(args)...); } }; template inline decltype(auto) MFP(F&& f){ return FixPoint{forward(f)}; } //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); Int n; cin>>n; vector> G(n); for(Int i=1;i>a>>b; a--;b--; G[a].emplace_back(b); G[b].emplace_back(a); } vector ans(n,0); MFP([&](auto dfs,Int v,Int p)->Int{ Int sz=0; for(Int u:G[v]){ if(u==p) continue; Int sb=dfs(u,v); ans[v]-=sb*sb; sz+=sb; } ans[v]+=sz*sz; ans[v]+=sz*2; ans[v]+=1; sz++; return sz; })(0,-1); for(Int a:ans) cout<