// Winding

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

namespace fastIO
{
	const UI BUFFER_SIZE = (UI) 1 << 15;
	char buffer[BUFFER_SIZE], *cur, *ed;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

template<typename T> inline T sqr(const T &val) { return val * val; }
template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

// END tpl.

const int MAXN = (int) 2e5;

int n;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i < n; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

namespace TREE
{
	int fa[MAXN + 5], mx[MAXN + 5];

	inline void dfs_init(int u, int fa0)
	{
		mx[u] = max(u, mx[fa[u] = fa0]);
		for(auto v : adj[u]) if(v != fa[u]) dfs_init(v, u);
	}
}

int val[MAXN + 5];

namespace DIV
{
	int cut[MAXN + 5], size[MAXN + 5];

	inline void dfs_size(int u, int fa)
	{
		size[u] = 1;
		for(auto v : adj[u]) if(!cut[v] && v != fa)
		{
			dfs_size(v, u);
			size[u] += size[v];
		}
	}

	inline int dfs_root(int u, int fa, int tot_size)
	{
		int fg = 1;
		for(auto v : adj[u]) if(!cut[v] && v != fa)
		{
			int p = dfs_root(v, u, tot_size);
			if(p) return p;
			if(size[v] * 2 > tot_size) fg = 0;
		}
		if((tot_size - size[u]) * 2 > tot_size) fg = 0;
		return fg ? u : 0;
	}

	inline void dfs_sub(int u, int fa, int mx, int *B, int &M)
	{
		B[++M] = mx;
		for(auto v : adj[u]) if(!cut[v] && v != fa) dfs_sub(v, u, max(v, mx), B, M);
	}

	int g[MAXN + 5];

	inline void calc(int u)
	{
		static int A[MAXN + 5];
		static int B[MAXN + 5];
		int N = 0, M = 0;

		for(int mx = 0, p = u; p && !cut[p]; p = TREE::fa[p])
		{
			chkmax(mx, p);
			if(mx <= val[p]) A[++N] = p;
		}
		dfs_sub(u, TREE::fa[u], u, B, M);

		sort(A + 1, A + N + 1, [] (int p, int q) { return val[p] < val[q]; });
		sort(B + 1, B + M + 1, [] (int p, int q) { return p < q; });

		for(int i = 1, j = 0; i <= N; ++i)
		{
			while(j < M && B[j + 1] <= val[A[i]]) ++j;
			g[A[i]] += j;
		}
	}

	inline void solve(int u)
	{
		dfs_size(u, 0), u = dfs_root(u, 0, size[u]);
		calc(u), cut[u] = 1;

		for(auto v : adj[u]) if(!cut[v]) solve(v);
	}
}

int f[MAXN + 5], ans[MAXN + 5];

inline void dfs_ans(int u)
{
	using namespace TREE;

	ans[u] = ans[fa[u]] - DIV::g[u] + f[u];
	for(auto v : adj[u]) if(v != fa[u]) dfs_ans(v);
}

inline void solve()
{
	using namespace TREE;

	dfs_init(1, 0);

	for(int i = 1; i <= n; ++i) val[i] = mx[fa[fa[i]]];
	DIV::solve(1);

	f[1] = 0;
	for(int u = 2; u <= n; ++u)
	{
		f[u] = 1;
		for(auto v : adj[u]) if(v != fa[u]) f[u] += DIV::g[v];
	}

	dfs_ans(1);
	for(int i = 2; i <= n; ++i) printf("%d ", ans[i]);
	puts("");
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 27392