#include #include #include #include using namespace std; using i64 = long long; using u64 = unsigned long long; using i32 = int; using u32 = unsigned int; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector> E; int main() { cin >> N; E.resize(N); rep(i,N-1){ int u,v; cin >> u >> v; u--; v--; E[u].push_back(v); E[v].push_back(u); } vector I = {0}; vector P(N,-1); rep(i,N){ int p = I[i]; for(int e : E[p]) if(P[p] != e){ P[e] = p; I.push_back(e); } } vector path(N, 0); for(int i=1; i i) ans++; rep(i,N) cout << (ans + path[i]) << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;