#include "bits/stdc++.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) using namespace std; using ld = long double; template using Table = vector>; const ld eps=1e-9; using Graph=vector>; using ll=long long; #define WHATS(var)cout<<__LINE__<<' '<<#var<<"="< ostream& operator <<(ostream &os, const pair v){ os << "( " << v.first << ", " << v.second << ")"; return os; } template ostream& operator <<(ostream &os, const vector &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template ostream& operator <<(ostream &os, const vector> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template ostream& operator <<(ostream &os, const vector> &v){ for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } template ostream& operator <<(ostream &os, const set &v){ int i=0; for(auto it:v){ if(i > 0){os << ' ';} os << it; i++; } return os; } ll dfs(int now,int from,const Graph&g,vector&anss){ ll sum=0; for(auto e:g[now]){ if(e!=from){ ll kk=dfs(e,now,g,anss); anss[now]-=kk*kk; sum+=kk; } } sum++; anss[now]+=ll(sum)*sum; return sum; } int main() { ios::sync_with_stdio(false); cin.tie(); int N;cin>>N; Graph g(N); for(int i=0;i>u>>v; u--;v--; g[u].push_back(v); g[v].push_back(u); } vectoranss(N); dfs(0,-1,g,anss); for(auto a:anss)cout<