#include<cstdio>
#include<algorithm>
using namespace std;
inline int read() {
	int x=0; char c=0;
	while(c<'0'||c>'9') c=getchar();
	while('0'<=c&&c<='9')x=10*x+c-'0',c=getchar();
	return x;
}
const int N=200005;
int head[N],ecnt;
int to[N<<1],nxt[N<<1];
inline void AddEdge(int u,int v) {
	to[++ecnt]=v, nxt[ecnt]=head[u], head[u]=ecnt;
	to[++ecnt]=u, nxt[ecnt]=head[v], head[v]=ecnt;
}
int n,ans[N];
int son[N],mv[N];
int siz[N],d[N];
int Calc(int u,int fa,int lim) {
	son[u]=1;
	for(int i=head[u];i;i=nxt[i]) {
		int v=to[i];
		if(v!=fa&&v<lim)
			son[u]+=Calc(v,u,lim);
	}
	return son[u];
}
int Dfs(int u,int fa) {
	mv[u]=max(mv[fa],u);
	siz[u]=1;
	for(int i=head[u];i;i=nxt[i]) {
		int v=to[i];
		if(v==fa) continue;
		siz[u]+=Dfs(v,u);
		d[u]+=d[v];
	}
	if(mv[u]==u) {
		Calc(u,fa,mv[fa]);
		d[u]=-siz[u];
	}
	if(mv[fa]==fa)
		d[u]+=siz[u];
	return siz[u];
}
void Solve(int u,int fa) {
	if(fa) {
		if(mv[u]==u) ans[u]+=son[u];
		else if(mv[fa]==fa) ans[u]+=d[u]-son[u];
		ans[u]+=ans[fa];
	}
	for(int i=head[u];i;i=nxt[i])
		if(to[i]!=fa) Solve(to[i],u);
}
int main() {
	n=read();
	for(int i=1;i<n;i++)
		AddEdge(read(),read());
	Dfs(1,0);
	Solve(1,0);
	for(int i=2;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
	return 0;
}