#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 222222;
vector<int> a[N];

int sz[N];
int level[N];
int tin[N], tout[N];
int timer = 0;
int ans[N];

void dfs_tin(int v, int p = -1) {
	tin[v] = timer++;
	for (int x : a[v]) {
		if (x == p) {
			continue;
		}
		dfs_tin(x, v);
	}
	tout[v] = timer;
}

void dfs_sz(int v, int p = -1) {
	for (int x : a[v]) {
		if (x == p) {
			continue;
		}
		level[x] = level[v] + 1;
		dfs_sz(x, v);
		sz[v] += sz[x];
	}
	++sz[v];
}

void remax(pair<int, int>& p, int v) {
	if (v > p.first) {
		p = {v, p.first};
	} else if (v > p.second) {
		p.second = v;
	}
}

vector<int> st;

void dfs(int v, pair<int, int> cur_mx, int p = -1) {
	st.push_back(v);
	remax(cur_mx, v);
	if (v > 0) {
		int tmp = cur_mx.first;
		if (level[cur_mx.second] > level[tmp]) {
			tmp = st[level[tmp] + 1];
		}
		ans[tin[tmp]] += 1;
		ans[tout[tmp]] -= 1;
	}
	for (int x : a[v]) {
		if (x == p) {
			continue;
		}
		dfs(x, cur_mx, v);
	}
	st.pop_back();
}

int main() {
	itn n = nxt();
	for (int i = 1; i < n; ++i) {
		int u = nxt() - 1, v = nxt() - 1;
		a[u].push_back(v);
		a[v].push_back(u);
	}

	dfs_tin(0);
	dfs_sz(0);
	dfs(0, {0, 0});
	for (int i = 1; i < n; ++i) {
		ans[i] += ans[i - 1];
	}
	for (int i = 1; i < n; ++i) {
		printf("%d ", ans[tin[i]]);
	}
	printf("\n");

	return 0;
}
