#include using namespace std; typedef pair P; typedef long long ll; typedef long double ld; const int inf=1e9+7; const ll longinf=1LL<<60; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) #define F first #define S second constexpr char ln = '\n'; const int mx=200010; const ll mod=1e9+7; vector v[mx]; vector ne(mx); vector cnt(mx,0); ll dfs(int x, int p){ ll tmp = 0; ne[x] = p; for(auto to:v[x]){ if(to==p) continue; tmp += dfs(to,x) + 1; } return cnt[x] = tmp; } int main(){ int n; cin >> n; rep(i,n-1){ int x,y; cin >> x >> y; x--; y--; v[x].emplace_back(y); v[y].emplace_back(x); } dfs(0,-1); rep(i,n){ vector a; ll sum = 0; for(auto to:v[i]){ if(to==ne[i]) continue; a.emplace_back(cnt[to]+1); sum += cnt[to]+1; } ll ans = 1; for(auto it:a){ ans += it*(sum-it); } ans += sum*2; cout << ans << ln; } return 0; }