#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, i, a, b, maxx[N], res[N];
VI graf[N];
map<int, int> mapa[N];

void dfs1(int w, int o) {
	if (o != -1) maxx[w] = max(maxx[o], o);
	for (auto &w2 : graf[w]) if (w2 != o) dfs1(w2, w);
}

int dfs2(int w, int o, int m) {
	if (mapa[w].find(m) != mapa[w].end()) return mapa[w][m];
	int res = 0;
	for (auto &w2 : graf[w]) if (w2 != o && w2 < m) res += (1 + dfs2(w2, w, m));
	mapa[w][m] = res;
	return res;
}

void dfs3(int w, int o) {
	for (auto &w2 : graf[w]) if (w2 != o) dfs3(w2, w);
	if (w == 0) return;
	res[w] = 1 + dfs2(w, o, maxx[w]);
	if (w < maxx[o]) res[w] -= (1 + dfs2(w, o, maxx[o]));
}

void dfs4(int w, int o) {
	if (w != 0) res[w] += res[o];
	for (auto &w2 : graf[w]) if (w2 != o) dfs4(w2, w);
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	graf[i].clear();
	maxx[i] = -1;
	res[i] = 0;
	mapa[i].clear();
}
for (i=1;i<n;i++) {
	scanf("%d %d", &a, &b);
	a--;
	b--;
	graf[a].pb(b);
	graf[b].pb(a);
}
dfs1(0, -1);
dfs3(0, -1);
dfs4(0, -1);
for (i=1;i<n;i++) printf("%d ", res[i]);
printf("\n");
return 0;
}

