#include #define rep(i,n) for(int i=0; i< (n); i++) using namespace std; typedef long long ll; typedef pair P; const int mod = 998244353; const int inf = (1<<30); const ll INF = (1ull<<62); int res = 0; vector ans(1e+5 + 7,-1); vector used(1e+5 + 7); void dfs(int x, vector> g){ used[x] = 1; for(int y : g[x]){ if(used[y] == 1) continue; if(x > y) res++; dfs(y,g); } return; } void dfs2(int x, vector> g){ ans[x] = res; for(int y : g[x]){ if(ans[y] != -1) continue; if(x > y) res--; else res++; dfs2(y,g); if(x > y) res++; else res--; } return; } int main(){ int n; cin>>n; vector> g(n); rep(i,n-1){ int a,b; cin>>a>>b; a--;b--; g[a].push_back(b); g[b].push_back(a); } dfs(0,g); dfs2(0,g); rep(i,n) cout<