//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 200111;
struct node
{
	int v, val, sum;
	int go[2];
}a[maxn];
int sz[maxn];
void update(int p)
{
	a[p].sum = a[p].val+a[a[p].go[0]].sum+a[a[p].go[1]].sum;
}
int merge(int p, int q)
{
	if (!p||!q) return p^q;
	if (a[p].v>a[q].v) swap(p, q);
	int ret = p;
	a[ret].go[1] = merge(a[ret].go[1], q);
	swap(a[ret].go[0], a[ret].go[1]);
	update(ret);
	return ret;
}
int pop(int &x)
{
	x = merge(a[x].go[0], a[x].go[1]);
}
int n;
vector<int> con[maxn];
int ans[maxn], fa[maxn];
int dp[maxn], dp2[maxn], tmp[maxn];
pair<int,int> mx[maxn];
vector<int> v[maxn];
void pdfs(int x, int pre=-1)
{
	sz[x] = 1;
	for (int i=0; i<con[x].size(); i++)
	{
		int u = con[x][i];
		if (u==pre) continue;
		mx[u] = max(MP(x, u), mx[x]);
		fa[u] = x;
		pdfs(u, x);
		sz[x] += sz[u];
	}
	v[mx[x].SS].PB(x);
}
int query(vector<int> &v, int x)
{
	return lower_bound(v.begin(), v.end(), x+1)-v.begin();
}
unordered_map<ll, int> mp;
int query_dfs(int x, int pre, int m)
{
	ll hs = 0;
	hs = hs*2333333+x;
	hs = hs*2333333+pre;
	hs = hs*2333333+m;
	if (mp.find(hs)!=mp.end()) return mp[hs];
	int &ret = mp[hs];
	if (x>m) return ret = 0;
	ret = 1;
	for (auto u: con[x])
	{
		if (u==pre) continue;
		ret += query_dfs(u, x, m);
	}
	return ret;
}
void dfs(int x, int pre=-1)
{
	if (x==1) dp[x] = 0;
	else
	{
		if (x>mx[x].FF)
		{
			dp[x] = dp[mx[x].FF]+1+query_dfs(mx[x].SS, mx[x].FF, mx[x].FF)-query_dfs(mx[x].SS, mx[x].FF, mx[mx[x].FF].FF);
			for (auto u: con[x])
			{
				if (u==pre) continue;
				dp[x] += query_dfs(u, x, mx[x].FF);
			}
		}
		else if (x==mx[x].SS)
		{
			dp[x] = dp[mx[x].FF]+1+query_dfs(mx[x].SS, mx[x].FF, mx[x].FF)-query_dfs(mx[x].SS, mx[x].FF, mx[mx[x].FF].FF)-1;
		}
		else dp[x] = dp[mx[x].SS];
		
	}
	for (int i=0; i<con[x].size(); i++)
	{
		int u = con[x][i];
		if (u==pre) continue;
		dfs(u, x);
	}
}
int main()
{
	geti(n);
	for (int i=1; i<n; i++)
	{
		int x, y;
		getii(x, y);
		con[x].PB(y);
		con[y].PB(x);
	}
	pdfs(1);
	for (int i=1; i<=n; i++) sort(v[i].begin(), v[i].end());
	dfs(1);
	for (int i=2; i<=n; i++) puti(dp[i]);
	return 0;
}


Measured memory_bytes: 48924