#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<vector<int> > G(n);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  
  vector<int> mx(n,0);
  function<void(int, int, int)> dfs1=
    [&](int v,int p,int d){
      chmax(mx[v],d);
      for(int u:G[v]){
        if(u==p) continue;
        dfs1(u,v,max(v,mx[v]));
      }      
    };
  dfs1(0,-1,0);
  
  vector<unordered_map<int, int> > dp(n);
  function<int(int, int, int)> dfs4=
    [&](int v,int p,int d){
      if(dp[v].count(d)) return dp[v][d];
      int &res=dp[v][d];
      res=v<d;
      for(int u:G[v]){
        if(u==p||u>d) continue;
        res+=dfs4(u,v,d);
      }
      return res;
    };
  
  vector<int> ans(n,0);
  function<void(int, int)> dfs2=
    [&](int v,int p){      
      for(int u:G[v]){
        if(u==p) continue;
        dfs2(u,v);
      }
      if(p<0) return;
      ans[v]=1+dfs4(v,p,mx[v]);
      if(mx[v]>v) ans[v]-=1+(v<mx[p]?dfs4(v,p,mx[p]):0);      
    };
  dfs2(0,-1);
  
  function<void(int, int)> dfs3=
    [&](int v,int p){
      for(int u:G[v]){
        if(u==p) continue;
        ans[u]+=ans[v];
        dfs3(u,v);
      }
    };
  dfs3(0,-1);

  for(int i=1;i<n;i++){
    if(i>1) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}
