#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 2e5 + 50;
int n; vector<int> G[N];
int sz[N], rt[N], fa[N];
int mx[N], se[N], dn[N];
namespace SGT{
	#define mid ((l+r)>>1)
	cs int N = ::N * 100;
	int lc[N], rc[N], A[N], B[N], nd;
	void ins(int &x, int l, int r, int p, bool typ){
		if(!x) x=++nd; if(l==r) return typ ? ++B[x] : ++A[x], void();
		(p<=mid)?ins(lc[x],l,mid,p,typ):ins(rc[x],mid+1,r,p,typ);
	}
	int mrg(int x, int y, int l, int r){
		if(!x||!y) return x|y;
		if(l==r){ int nx=++nd; A[nx]=A[x]+A[y]; B[nx]=B[x]+B[y]; return nx; }
		int nx=++nd; lc[nx]=mrg(lc[x],lc[y],l,mid);
		rc[nx]=mrg(rc[x],rc[y],mid+1,r); return nx;
	}
	int qry(int x, int l, int r, int p, int typ){
		if(!x) return 0; if(l==r) return typ ? B[x] : A[x];
		if(p<=mid) return qry(lc[x],l,mid,p,typ);
		return qry(rc[x],mid+1,r,p,typ);
	}
}
void dfs(int u, int f){
	mx[u]=mx[f]; se[u]=se[f];
	if(u>mx[u]) se[u]=mx[u], mx[u]=u;
	else if(u>se[u]) se[u]=u;
	sz[u]=1; SGT::ins(rt[u],1,n,mx[u],0);
	SGT::ins(rt[u],1,n,se[u],1);
	if(mx[u]==mx[f]){
		if(mx[f]==f) dn[u]=u;
		else dn[u]=dn[f];
	} 
	
	for(int e=0,v;e<G[u].size();e++)
	if((v=G[u][e])!=f){
		fa[v]=u; dfs(v,u); sz[u]+=sz[v];
		rt[u]=SGT::mrg(rt[u],rt[v],1,n);
	}
} int as[N];
void cope(int u, int f){
	if(f){
		if(u==mx[u]) as[u]=as[f]+SGT::qry(rt[u],1,n,se[u],1);
		else{
			as[u]=as[fa[mx[u]]];
			as[u]+=SGT::qry(rt[dn[u]],1,n,mx[u],0);
			as[u]+=SGT::qry(rt[mx[u]],1,n,se[mx[u]],1);
			as[u]-=SGT::qry(rt[dn[u]],1,n,se[mx[u]],1);
		}
	} for(int e=0,v;e<G[u].size();e++)
	if((v=G[u][e])!=f) cope(v,u);
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d",&n);
	for(int i=1,u,v; i<n; i++)
	scanf("%d%d",&u,&v), G[u].pb(v), G[v].pb(u);
	dfs(1,0); cope(1,0);
	for(int i=2; i<=n; i++) cout<<as[i]<<" ";
	return 0;
} 