#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_N = (1 << 18);

struct Node {
	int val, l, r;
};

class BinarySearchTree {
public:
	vector<Node>T;

	int getsize() {
		return T[0].val;
	}
	void init() {
		T.push_back(Node{ 0, -1, -1 });
	}
	void add(int pos) {
		int cx = 0;
		for (int i = 17; i >= 0; i--) {
			int bit = 0; if ((pos & (1 << i)) != 0) bit = 1;

			T[cx].val++;
			if (bit == 0) {
				if (T[cx].l == -1) { T[cx].l = T.size(); T.push_back(Node{ 0, -1, -1 }); }
				cx = T[cx].l;
			}
			if (bit == 1) {
				if (T[cx].r == -1) { T[cx].r = T.size(); T.push_back(Node{ 0, -1, -1 }); }
				cx = T[cx].r;
			}
		}
		T[cx].val++;
	}
	int sum(int pos) {
		if (pos <= -1) return 0;

		int sums = 0, cx = 0; bool used = false;
		for (int i = 17; i >= 0; i--) {
			int bit = 0; if ((pos & (1 << i)) != 0) bit = 1;

			if (bit == 0) {
				if (T[cx].l == -1) { used = true; break; }
				cx = T[cx].l;
			}
			if (bit == 1) {
				if (T[cx].l >= 0) sums += T[T[cx].l].val;
				if (T[cx].r == -1) { used = true; break; }
				cx = T[cx].r;
			}
		}
		if (used == false) sums += T[cx].val;
		return sums;
	}
	int getsum(int l, int r) {
		return sum(r) - sum(l - 1);
	}
};

int N, A[MAX_N], B[MAX_N], par[MAX_N], maxbit[MAX_N], lc[MAX_N], rc[MAX_N], cnt;
vector<pair<int, int>> Z[MAX_N];
vector<int> X[MAX_N], Y[MAX_N];
bool used[MAX_N];

BinarySearchTree G[MAX_N]; vector<int>GG[MAX_N]; int Group[MAX_N];
vector<int>I[MAX_N], J[MAX_N];

void unite(int x, int y) {
	x = Group[x]; y = Group[y];
	if (GG[x].size() < GG[y].size()) swap(x, y);

	for (int i = 0; i < GG[y].size(); i++) {
		int rem = GG[y][i];
		G[x].add(lc[rem]); GG[x].push_back(rem); Group[rem] = x;
	}
}
int getnum(int pos) {
	return G[Group[pos]].getsum(lc[pos], rc[pos]);
}

void dfs(int pos) {
	used[pos] = true; cnt++; lc[pos] = cnt; maxbit[pos] = max(maxbit[pos], pos);
	for (int i = 0; i < X[pos].size(); i++) {
		if (used[X[pos][i]] == true) continue;
		par[X[pos][i]] = pos; maxbit[X[pos][i]] = max(maxbit[X[pos][i]], maxbit[pos]);
		Y[pos].push_back(X[pos][i]);
		dfs(X[pos][i]);
	}
	rc[pos] = cnt;
}

int Score[MAX_N];

void dfs2(int pos, int score) {
	int cnt = 0; for (int i = 0; i < Y[pos].size(); i++) cnt += I[pos][i];
	Score[pos] = score + cnt;

	for (int i = 0; i < Y[pos].size(); i++) {
		dfs2(Y[pos][i], score + cnt - I[pos][i] + 1);
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
		Z[max(A[i], B[i])].push_back(make_pair(A[i], B[i]));
	}
	for (int i = 1; i <= N; i++) { G[i].init(); Group[i] = i; GG[i].push_back(i); }
	dfs(1);
	for (int i = 1; i <= N; i++) G[i].add(lc[i]);
	for (int i = 2; i <= N; i++) J[maxbit[par[i]]].push_back(i);

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j < Z[i].size(); j++) unite(Z[i][j].first, Z[i][j].second);

		for (int pos : J[i]) {
			for (int j = 0; j < Y[pos].size(); j++) {
				int to = Y[pos][j];
				if (to > i) I[pos].push_back(0);
				else I[pos].push_back(getnum(to));
			}
		}
	}
	while (I[1].size() < Y[1].size()) I[1].push_back(0);

	dfs2(1, 0);
	for (int i = 2; i <= N; i++) { if (i >= 3) cout << " "; cout << Score[i]; } cout << endl;
	return 0;
}

Measured memory_bytes: 216008