#pragma GCC optimize("Ofast") #include #define rep(i,n) for(int i=0;i>x[i]; #define ft first #define sc second #define pb push_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(),(v).end() #define LB(a,x) lb(all(a),x)-a.begin() #define UB(a,x) ub(all(a),x)-a.begin() #define mod 1000000007 //#define mod 998244353 #define FS fixed< using V=vector; using Graph = vector>; using P=pair; typedef unsigned long long ull; typedef long double ldouble; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline void out(T a){ cout << a << '\n'; } void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;} //void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;} const ll INF=1e18; const int mx=200005; V> G; V a,b; void dfs(ll v,ll p){ ll tmp1=0,tmp2=0; for(ll u:G[v]){ if(u==p) continue; dfs(u,v); a[v]+=a[u]; tmp1+=a[u]; tmp2+=a[u]*a[u]; } a[v]++; b[v]=(tmp1*tmp1-tmp2)/2; } int main(){ cin.tie(0);ios::sync_with_stdio(false); ll n; cin>>n; G.resize(n); a.resize(n); b.resize(n); rep(i,n-1){ ll u,v; cin>>u>>v; u--;v--; G[u].pb(v); G[v].pb(u); } rep(i,n) a[i]=0; dfs(0,-1); rep(i,n) cout<<2*a[i]+2*b[i]-1<