#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<