#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
    using namespace std;
    #define pii pair<int,int>
    #define fir first
    #define sec second
    #define MP make_pair
    #define rep(i,x,y) for (int i=(x);i<=(y);i++)
    #define drep(i,x,y) for (int i=(x);i>=(y);i--)
    #define go(x) for (int i=head[x];i;i=edge[i].nxt)
    #define templ template<typename T>
    #define sz 202020
    typedef long long ll;
    typedef double db;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
    templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
    templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
    templ inline void read(T& t)
    {
        t=0;char f=0,ch=getchar();double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t=(f?-t:t);
    }
    template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
    char __sr[1<<21],__z[20];int __C=-1,__zz=0;
    inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
    inline void print(register int x)
    {
        if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
        while(__z[++__zz]=x%10+48,x/=10);
        while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
    }
    void file()
    {
        #ifdef NTFOrz
        freopen("a.in","r",stdin);
        #endif
    }
    inline void chktime()
    {
        #ifndef ONLINE_JUDGE
        cout<<(clock()-t)/1000.0<<'\n';
        #endif
    }
    #ifdef mod
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
    ll inv(ll x){return ksm(x,mod-2);}
    #else
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
    #endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
struct hh{int t,nxt;}edge[sz<<1];
int head[sz],ecnt;
void make_edge(int f,int t)
{
	edge[++ecnt]=(hh){t,head[f]};
	head[f]=ecnt;
	edge[++ecnt]=(hh){f,head[t]};
	head[t]=ecnt;
}
#define v edge[i].t

int root[sz];
#define Tree sz*40
int tr[Tree],ch[Tree][2],cc;
#define ls ch[k][0]
#define rs ch[k][1]
#define lson ls,l,mid
#define rson rs,mid+1,r
void pushup(int k){tr[k]=tr[ls]+tr[rs];}
void add(int &k,int l,int r,int x,int w)
{
	if (!k) k=++cc;
	tr[k]+=w;
	if (l==r) return;
	int mid=(l+r)>>1;
	if (x<=mid) add(lson,x,w);
	else add(rson,x,w);
}
void clear(int &k,int l,int r,int x,int y)
{
	if (x>y||!k) return;
	if (x<=l&&r<=y) return k=0,void();
	int mid=(l+r)>>1;
	if (x<=mid) clear(lson,x,y);
	if (y>mid) clear(rson,x,y);
	pushup(k);
}
int query(int k,int l,int r,int x,int y)
{
	if (x>y||!k) return 0;
	if (x<=l&&r<=y) return tr[k];
	int mid=(l+r)>>1,ret=0;
	if (x<=mid) ret+=query(lson,x,y);
	if (y>mid) ret+=query(rson,x,y);
	return ret;
}
int merge(int k1,int k2)
{
	if (!k1||!k2) return k1+k2;
	tr[k1]+=tr[k2];
	ch[k1][0]=merge(ch[k1][0],ch[k2][0]);
	ch[k1][1]=merge(ch[k1][1],ch[k2][1]);
	return k1;
}

int sum[sz],cnt[sz];
void dfs(int x,int fa,int mx)
{
	go(x) if (v!=fa) dfs(v,x,max(mx,x));
	go(x) if (v!=fa) sum[x]+=(cnt[v]=query(root[v],1,n,1,mx));
	go(x) if (v!=fa) root[x]=merge(root[v],root[x]);
	int s=query(root[x],1,n,1,x-1);clear(root[x],1,n,1,x-1);add(root[x],1,n,x,s+1);
}
int cur;
int ans[sz];
void dfs2(int x,int fa,int dep)
{
	ans[x]=sum[x]+cur+dep;
	go(x) if (v!=fa) cur+=sum[x]-cnt[v],dfs2(v,x,dep+1),cur-=sum[x]-cnt[v];
}

int main()
{
    file();
	read(n);
	int x,y;
	rep(i,1,n-1) read(x,y),make_edge(x,y);
	dfs(1,0,0);dfs2(1,0,0);
	rep(i,2,n) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 57600