#include <bits/stdc++.h>
#define N 200005
using namespace std;

int f[N],n,tot;
vector<int>to[N];

inline int read()
{
	int ans=0,f=1;char c=getchar();
	while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans*f;
}

void dfs(int x,int ga,int va,int gb,int fa)
{
	if(x>ga)va=ga,ga=x,gb=0,++f[x];
	else
	{
		if(fa==ga)gb=x;
		if(x>va)va=0;
		if(x<=va)++f[ga];else ++f[gb];
	}
	for(auto v:to[x]) if(v!=fa) dfs(v,ga,va,gb,x);
}

void dfs2(int x,int fa)
{
	f[x]+=f[fa];
	for(auto v:to[x]) if(v!=fa) dfs2(v,x);
}
int main()
{
	n=read();
	int x,y;
	for(int i=1;i<n;++i)
		x=read(),y=read(),to[x].push_back(y),to[y].push_back(x);
	dfs(1,0,0,0,0);dfs2(1,0);
	for(int i=2;i<=n;++i)printf("%d ",f[i]-1);
}
