#include using namespace std; int N; long long dp[200005]; vectorki[200005]; int dfs(int n,int p) { vectortmp; for(auto x:ki[n]) { if(x != p) { tmp.push_back(dfs(x,n)); } } int ans = 1; for(int i = 0; i < tmp.size(); i++) { ans += tmp[i]; } long long ans2 = ans; for(int i = 0; i < tmp.size(); i++) { ans2 += (long long)(ans-tmp[i])*tmp[i]; } dp[n] = ans2; return ans; } int main() { cin >> N; for(int i = 0; i < N-1; i++) { int u,v; cin >> u >> v; u--;v--; ki[u].push_back(v); ki[v].push_back(u); } dfs(0,-1); for(int i = 0; i < N; i++) { cout << dp[i] << endl; } }