#include <bits/stdc++.h>

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 2E5 + 10;

int n;
vector<int> E[N];
int sz[N];
int rt[N];

int s1[N], s2[N];	// less grandfather, less father
int sv1[N];	// sum less grandfather
int ans[N];

struct node{
	int s, l, r;
}a[N * 20];
int tot = 1;

int gen(int l, int r, int L){
	int u = tot++;
	a[u].s = 1;
	if (l + 1 == r)
		return u;
	int m = l + r >> 1;
	if (L < m)
		a[u].l = gen(l, m, L);
	else
		a[u].r = gen(m, r, L);
	return u;
}

int merge(int u, int v, int l, int r){
	if (u == 0 || v == 0)
		return u | v;

	int m = l + r >> 1;
	a[u].s += a[v].s;
	a[u].l = merge(a[u].l, a[v].l, l, m);
	a[u].r = merge(a[u].r, a[v].r, m, r);
	return u;
}

void update(int u, int l, int r, int L, int C){
	a[u].s += C;
	if (l + 1 == r)
		return;
	int m = l + r >> 1;
	if (L < m)
		update(a[u].l, l, m, L, C);
	else
		update(a[u].r, m, r, L, C);
}

int queryLess(int u, int l, int r, int L){
	if (l + 1 == r)
		return 0;
	int m = l + r >> 1;
	return L < m ? queryLess(a[u].l, l, m, L) :
		a[a[u].l].s + queryLess(a[u].r, m, r, L);
}

int cutLess(int u, int l, int r, int L){
	if (l + 1 == r)
		return 0;
	int m = l + r >> 1, ret = 0;
	if (L < m)
		ret = cutLess(a[u].l, l, m, L);
	else{
		ret = a[a[u].l].s;
		a[u].l = 0;
		ret += cutLess(a[u].r, m, r, L);
	}
	a[u].s -= ret;
}

void DFS(int u, int pre, int premax){
	rt[u] = gen(1, n + 1, u);
	for (auto &v: E[u]){
		if (v == pre)
			continue;
		DFS(v, u, max(premax, pre));

		sv1[u] += s1[v];
		rt[u] = merge(rt[u], rt[v], 1, n + 1);
	}
	if (pre != 1){
		s2[u] = cutLess(rt[u], 1, n + 1, u);
		update(rt[u], 1, n + 1, u, s2[u]);
		s2[u] = queryLess(rt[u], 1, n + 1, pre);
		if (premax < u)
			s1[u] = 0;
		else
			s1[u] = queryLess(rt[u], 1, n + 1, premax);
	}
}

void DFS2(int u, int pre, int presum){
	eput(u, s1[u], sv1[u]);
	if (pre == 1)
		ans[u] = 1;
	else{
		ans[u] = presum + sv1[u] + 1;
	}
	for (auto &v: E[u]){
		if (v == pre)
			continue;
		DFS2(v, u, presum + sv1[u] - s1[v] + 1);
	}
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	for (auto &v: E[1])
		DFS(v, 1, 0);
	for (auto &v: E[1])
		DFS2(v, 1, 0);
	for (int i = 2; i <= n; ++i)
		printf("%d%c", ans[i], "\n "[i < n]);
	return 0;
}


Measured memory_bytes: 76672