#include <bits/stdc++.h>
using namespace std;

vector <int> from[200010];
int dp[200010][3];
int maxj[200010];
int ans[200010];

void dfs(int x, int last) {
	for (int i = 0; i < from[x].size(); i++) {
		int v = from[x][i];
		if (v == last) continue;
		maxj[v] = max(maxj[x], x), dfs(v, x);
	}
	if (x == 1) return ;
	if (x > maxj[x]) {
		dp[x][0] = 1;
		for (int i = 0; i < from[x].size(); i++) {
			int v = from[x][i];
			if (v == last) continue;
			if (v <= maxj[x]) dp[x][0] += dp[v][1];
		}
		ans[x] = dp[x][0];
	} else if (maxj[x] == last) {
		dp[x][0] = 1, dp[x][1] = x <= maxj[last];
		for (int i = 0; i < from[x].size(); i++) {
			int v = from[x][i];
			if (v == last) continue;
			if (v <= maxj[x]) dp[x][0] += dp[v][0];
			if (v <= maxj[last] && x <= maxj[last]) dp[x][1] += dp[v][2];
		}
		ans[x] = dp[x][0] - dp[x][1];
	} else {
		dp[x][0] = dp[x][1] = dp[x][2] = 1;
		for (int i = 0; i < from[x].size(); i++) {
			int v = from[x][i];
			if (v == last) continue;
			if (v <= maxj[x]) dp[x][0] += dp[v][0];
			if (v <= maxj[last]) dp[x][1] += dp[v][1];
			if (v <= maxj[maxj[last]]) dp[x][2] += dp[v][2];
		}
		ans[x] = 0;
	}
}

void get_ans(int x, int last) {
	ans[x] += ans[last];
	for (int i = 0; i < from[x].size(); i++) {
		int v = from[x][i];
		if (v == last) continue;
		get_ans(v, x);
	}
}

int main () {
	int n; scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v; scanf("%d%d", &u, &v);
		from[u].push_back(v), from[v].push_back(u);
	}
	dfs(1, 1), get_ans(1, 1);
	for (int i = 2; i <= n; i++) {
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}
