#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 2e5 + 5;
int head[MAXN] , to[MAXN << 1] , nxt[MAXN << 1] , cnt;
void add(int u , int v) {nxt[++cnt] = head[u];head[u] = cnt;to[cnt] = v;}
int mx[MAXN] , n , c[MAXN];
map <int , int> M[MAXN];
int Q(int x , int val , int fa) {
	if(M[x][val]) return M[x][val];
	for (int i = head[x]; i; i = nxt[i]) {
		if(to[i] == fa) continue;
		if(to[i] < val) M[x][val] += Q(to[i] , val , x) + 1;
	}
	return M[x][val];
}
void dfs(int x , int fa) {
	mx[x] = max(mx[fa] , x);
	for (int i = head[x]; i; i = nxt[i]) {
		if(to[i] == fa) continue;
		if(to[i] < mx[x] && x > mx[fa]) {
			if(to[i] < mx[fa]) c[to[i]] = c[x] + Q(to[i] , mx[x] , x) - Q(to[i] , mx[fa] , x);
			else c[to[i]] = c[x] + Q(to[i] , mx[x] , x) + 1;
		}
		else if(to[i] < mx[x]) c[to[i]] = c[x];
		else c[to[i]] = c[x] + Q(to[i] , mx[x] , x) + 1;
		dfs(to[i] , x);
	}
}
int main() {
	scanf("%d" , &n);
	for (int i = 1; i < n; ++i) {
		int u , v;
		scanf("%d %d" , &u , &v);
		add(u , v);add(v , u);
	}
	dfs(1 , 0);
	for (int i = 2; i <= n; ++i) printf("%d " , c[i]);
	return 0;
}