#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;

#define LL long long
#define DB double
#define MAXN 2000000
#define MOD 998244353
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int n,f[MAXN+5],mx[MAXN+5],ans[MAXN+5];
vector<int> G[MAXN+5];
int a[MAXN+5],b[MAXN+5];

int C(int x,int val){
	if(x>val)return 0;
	int res=1;
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==f[x])continue;
		res+=C(v,val);
	}return res;
}
void dfs1(int x){
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==f[x])continue;
		f[v]=x,mx[v]=max(mx[x],v);
		dfs1(v);
	}
	if(mx[x]>mx[f[x]]){
		b[x]=1;
		for(int i=0;i<G[x].size();i++){
			int v=G[x][i];
			if(v==f[x])continue;
			int tmp=C(v,mx[f[x]]);
			a[v]=C(v,mx[x])-tmp;
			b[x]+=tmp;
		}
	}
}
void dfs2(int x){
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==f[x])continue;
		ans[v]=ans[x];
		if(mx[x]>mx[f[x]])ans[v]+=a[v];
		if(mx[v]>mx[x])ans[v]+=b[v];
		dfs2(v);
	}
}

int main(){
	n=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u); 
	}
	mx[1]=1;dfs1(1);
	dfs2(1);
	for(int i=2;i<=n;i++)printf("%d ",ans[i]);
}