#include <bits/stdc++.h>

const int MAXN = 200010;
int head[MAXN], nxt[MAXN << 1], to[MAXN << 1], tot;
void addedge(int b, int e) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e;
	nxt[++tot] = head[e]; to[head[e] = tot] = b;
}
int f[MAXN], n;
void dfs(int u, int ga = 0, int va = 0, int gb = 0, int fa = 0) {
	if (u > ga) va = ga, ga = u, gb = 0, ++f[u];
	else {
		if (fa == ga) gb = u;
		if (u > va) va = 0;
		if (u <= va) ++f[ga]; else ++f[gb];
	}
	for (int i = head[u]; i; i = nxt[i]) if (to[i] != fa)
		dfs(to[i], ga, va, gb, u);
}
void dfs2(int u, int fa = 0) {
	f[u] += f[fa];
	for (int i = head[u]; i; i = nxt[i]) if (to[i] != fa) dfs2(to[i], u);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, t1, t2; i < n; ++i)
		std::cin >> t1 >> t2, addedge(t1, t2);
	dfs(1); dfs2(1);
	for (int i = 2; i <= n; ++i) std::cout << f[i] - 1 << ' ';
	std::cout << std::endl;
	return 0;
}
