/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 10;

vector<int> g[N], stk;
int pref_max[N], ans[N], lazy[N];

void dfs(int u, int p, int mxp, int since);
void dfs2(int u, int p, int lz);

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].pb(v); g[v].pb(u);
	}
	stk.pb(0);
	dfs(1, 0, 1, 0);
	dfs2(1, 0, 0);
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] - 1 << ' ';
	}
	cout << endl;
}

void dfs(int u, int p, int mxp, int since) {
	stk.pb(u);
	int k = stk.size();
	pref_max[k - 1] = max(pref_max[k - 2], u);
	int ch = stk[mxp];
	if (mxp < k - 1) {
		ch = stk[mxp + 1];
		if (pref_max[mxp - 1] > since) {
			ch = stk[mxp];
		}
	}
	++lazy[ch];
	for (auto &v : g[u]) {
		if (v == p) {
			continue;
		}
		if (v < stk[mxp]) {
			dfs(v, u, mxp, max(since, v));
		} else {
			dfs(v, u, k, 0);
		}
	}
	stk.pop_back();
}

void dfs2(int u, int p, int lz) {
	ans[u] = lz + lazy[u];
	for (auto &v : g[u]) {
		if (v == p) {
			continue;
		}
		dfs2(v, u, lz + lazy[u]);
	}
}