#include<iostream>
using namespace std;
#define MAXN 10000
#define INF 999999
struct Edge { int v, next; };
Edge edge[MAXN];
int dfn[MAXN], low[MAXN];
int stk[MAXN], top, id;
int head[MAXN], E;
int dis[MAXN], block[MAXN];
void add_edge ( int u, int v )
{
E++;
edge[E].v = v;
edge[E].next = head[u];
head[u] = E;
}
void Tarjan ( int u, int father )
{
stk[++top] = u;
dfn[u] = low[u] = ++id;
for ( int i = head[u]; i != -1; i = edge[i].next )
{
if ( edge[i].v == father ) continue;
if ( dfn[edge[i].v] == 0 )
{
Tarjan ( edge[i].v, u );
low[u] = min ( low[u], low[edge[i].v] );
if ( low[edge[i].v] > dfn[u] )
top--;
else if ( low[edge[i].v] == dfn[u] )
{
int t, cnt = 0;
do
{
t = stk[top--];
block[++cnt] = t;
} while ( t != u );
}
}
else
low[u] = min ( low[u], dfn[edge[i].v] );
}
}
void BFS ()
{
int que[MAXN];
bool vis[MAXN] = { 0 };
int front = 0, rear = 0;
que[rear++] = block[1];
vis[block[1]] = true;
while ( front < rear )
{
int u = que[front++];
for ( int i = head[u]; i != -1; i = edge[i].next )
{
if ( ! vis[edge[i].v] )
{
if ( dis[edge[i].v] == INF )
dis[edge[i].v] = dis[u] + 1;
que[rear++] = edge[i].v;
vis[edge[i].v] = true;
}
}
}
}
int main()
{
int n, u, v;
cin >> n;
for ( int i = 0; i < n * 2 + 1; i++ )
{
head[i] = block[i] = -1;
dfn[i] = low[i] = 0;
dis[i] = INF;
E = top = id = 0;
}
for ( int i = 1; i <= n; i++ )
{
cin >> u >> v;
add_edge ( u, v );
add_edge ( v, u );
}
Tarjan ( 1, 0 );
for ( int i = 1; i <= n; i++ )
dis[block[i]] = 0;
BFS();
for ( int i = 1; i < n; i++ )
cout << dis[i] << ' ';
cout << dis[n] << endl;
return 0;
}