#include<bits/stdc++.h>
#define N 200100
#define T 4001000
#define fo(i,a,b) for(int i=a,_E_=b;i<_E_;++i)
using namespace std;
int n,mx[N],sm[N],fa[N],res[N],s[N],ct[N],c[N],c2[N];
int son[T][2],cnt,sz[T],rt[N],opl;
vector<int> r[N];

void ins(int &x,int h,int t){
	x=++cnt;++sz[x];
	if(h==t)return;
	int m=h+t>>1;
	if(opl<=m)ins(son[x][0],h,m);else ins(son[x][1],m+1,t);
}
void merge(int &u,int v,int h,int t){
	if(!u||!v){u^=v;return;}
	sz[u]+=sz[v];
	if(h==t)return;
	int m=h+t>>1;
	merge(son[u][0],son[v][0],h,m);
	merge(son[u][1],son[v][1],m+1,t);	
}
int query(int x,int h,int t){
	if(h==t)return sz[x];
	int m=h+t>>1;
	if(opl<=m)return query(son[x][0],h,m);
	return query(son[x][1],m+1,t);
}

void dfs(int x,int M,int S,int nx){
	if(x>M)S=M,M=x;else if(x>S)S=x;
	sm[x]=S;mx[x]=M;s[x]=nx;
	if(x^M)++ct[nx];
	opl=sm[x];ins(rt[x],1,n);
	fo(i,0,r[x].size()){
		int y=r[x][i];if(y==fa[x])continue;
		fa[y]=x;dfs(y,M,S,M==x?y:nx);
		merge(rt[x],rt[y],1,n);
	}opl=sm[x];
	c[x]=query(rt[x],1,n);
	opl=sm[fa[x]];
	c2[x]=query(rt[x],1,n);
}
void calc(int x){
	if(x^1){
		res[x]=res[fa[mx[x]]]+c[mx[x]];
		if(mx[x]^x)res[x]+=ct[s[x]]-c2[s[x]];
	}
	fo(i,0,r[x].size()){
		int y=r[x][i];
		if(y==fa[x])continue;
		calc(y);
	}
}

int main(){
	scanf("%d",&n);
	fo(i,1,n){
		int x,y;scanf("%d %d",&x,&y);
		r[x].push_back(y);r[y].push_back(x);
	}dfs(1,0,0,1);
	calc(1);
	fo(i,1,n)printf("%d ",res[i+1]);
}