#include<iostream>
#include<cstdio>
#define RT(x) rt[x],1,n
#define lson ls[u],l,md
#define rson rs[u],md+1,r
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(u) for(int i=hd[u],v;v=e[i].v,i;i=e[i].n)
using namespace std;
const int N=200200,TO=N*40;
int n,m,fl,u,v,cnt;
int hd[N],fa[N],mx[N],se[N],fd[N],rt[N],ans[N],f[N],g[N];
int ls[TO],rs[TO],s[2][TO];
struct edge{int n,v;}e[N<<1];
void add(int u,int v){e[++fl]=(edge){hd[u],v};hd[u]=fl;}
void dfs1(int u,int w){
	if(mx[u]==fa[u]) w=u;fd[u]=w;
	REP(u)if(v!=fa[u]){
		fa[v]=u;mx[v]=mx[u],se[v]=se[u];
		if(v>mx[u]) mx[v]=v,se[v]=mx[u];
		else if(v>se[u]) se[v]=v;
		dfs1(v,v==mx[v]?v:w);
	}
}
void ins(int&u,int l,int r,int x,int k){
	if(!u) u=++cnt;s[k][u]++;
	if(l==r) return;
	int md=(l+r)>>1;
	x<=md?ins(lson,x,k):ins(rson,x,k);
}
int  ask(int&u,int l,int r,int x,int k){
	if(l==r) return s[k][u];
	int md=(l+r)>>1;
	return x<=md?ask(lson,x,k):ask(rson,x,k);
}
int mrg(int u,int l,int r,int v){
	if(!u||!v) return u|v;
	s[0][u]+=s[0][v];
	s[1][u]+=s[1][v];
	if(l==r) return u;
	int md=(l+r)>>1;
	ls[u]=mrg(lson,ls[v]);
	rs[u]=mrg(rson,rs[v]);
	return u;
}
void dfs2(int u){
	ins(RT(u),mx[u],0);ins(RT(u),se[u],1);
	REP(u)if(v!=fa[u]) dfs2(v),rt[u]=mrg(RT(u),rt[v]);
	if(mx[u]==fa[u]) f[u]=ask(RT(u),mx[u],0),g[u]=ask(RT(u),se[fa[u]],1);
	if(mx[u]==u) g[u]=ask(RT(u),se[u],1);
}
void dfs3(int u){
	if(u==mx[u]) ans[u]=g[u]+ans[fa[u]];
	else if(u>1) ans[u]=g[mx[u]]-g[fd[u]]+f[fd[u]]+ans[fa[mx[u]]];
	REP(u)if(v!=fa[u]) dfs3(v);
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,2,n) scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs1(1,0);dfs2(1);dfs3(1);
	//FOR(i,1,n) cout<<f[i]<<' '<<g[i]<<' '<<mx[i]<<'\n';
	FOR(i,2,n) cout<<ans[i]<<' ';cout<<'\n';
}