#include <iostream>
#include <vector>

using namespace std;

struct SegTree{
	int size;
	vector<int> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = 0;
	}
	
	void add(int i, int val)
	{
		i += (1 << size);
		seg[i] += val;
		while(i > 1){
			i /= 2;
			seg[i] = seg[i*2] + seg[i*2+1];
		}
	}

	int query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return 0;
		if(a <= l && r <= b) return seg[k];
		int lval = query(a, b, k*2, l, (l+r)/2);
		int rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return lval + rval;
	}
	int query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

int n;
vector<int> G[200005];
int parent[200005];
int p[200005], pp[200005];
int num[200005], num2[200005];
int ans[200005];

void pardfs(int v, int pre)
{
	parent[v] = pre;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == pre) continue;
		pardfs(G[v][i], v);
	}
}

/*void defpdfs(int v, int pre)
{
	if(p[pre] <= v) p[v] = pre;
	else{
		if(p[pre] <= pre) p[v] = pre;
		else p[v] = p[pre];
	}
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == pre) continue;
		defpdfs(G[v][i], v);
	}
}*/

void defpdfs(int v, int pre)
{
	p[v] = max(p[pre], pre);
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == pre) continue;
		defpdfs(G[v][i], v);
	}
}

void ansdfs(int v, int pre, int sum)
{
	ans[v] = sum + num[v];
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == pre) continue;
		ansdfs(G[v][i], v, sum + num[v] - num2[G[v][i]]);
	}
}

int id = 0;
int l[200005], r[200005];
void travdfs(int v, int pre)
{
	l[v] = id++;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == pre) continue;
		travdfs(G[v][i], v);
	}
	r[v] = id++;
}

vector<int> vec[200005];
SegTree seg(19);
UnionFind uf(200005);
void solve(int p[], int num[])
{
	seg.init();
	for(int i = 0; i <= n; i++) vec[i].clear();
	for(int i = 1; i <= n; i++) vec[p[i]].push_back(i);
	
	uf.init();
	for(int i = 0; i <= n; i++){
		for(int j = 0; j < vec[i].size(); j++){
			int v = vec[i][j];
			num[v] = seg.query(l[v], r[v]) + 1;
		}
		if(i <= 1) continue;
		int rt = uf.root(parent[i]), x = seg.query(l[i], r[i])+1;
		uf.unite(i, parent[i]);
		seg.add(l[parent[i]], x);
		if(rt != 1) seg.add(l[parent[rt]], -x);
	}
}

int main(void)
{
	cin >> n;
	int a, b;
	for(int i = 1; i <= n-1; i++){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	pardfs(1, 0);
	travdfs(1, 0);
	defpdfs(1, 0);
	
	solve(p, num);
	for(int i = 1; i <= n; i++) pp[i] = p[parent[i]];
	solve(pp, num2);
	for(int i = 1; i <= n; i++) if(pp[i] < i) num2[i] = 0;
	
	ansdfs(1, 0, 0);
	for(int i = 2; i <= n; i++) cout << ans[i]-1 << " "; cout << endl;
	
	return 0;
}

Measured memory_bytes: 44920