import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

n = int(input())
graph = [[] for _ in range(n)]

for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

# 모든 노드마다 사이클에 포함되는지 확인
is_cycle = [False] * n
visited = []


def check_cycle(node, cur, start, cnt):
    if cur == start and cnt >= 2:
        is_cycle[node] = True
        return

    visited[cur] = True
    for next_node in graph[cur]:
        if not visited[next_node]:
            check_cycle(node, next_node, start, cnt + 1)
        elif next_node == start and cnt >= 2:
            check_cycle(node, next_node, start, cnt)


for i in range(n):
    visited = [False] * n
    check_cycle(i, i, i, 0)

# 사이클에서 얼마나 떨어져있는지 확인
result = [-1] * n
queue = deque()

for i in range(n):
    if is_cycle[i]:
        result[i] = 0
        queue.append(i)

while queue:
    node = queue.popleft()

    for next_node in graph[node]:
        if result[next_node] == -1:
            queue.append(next_node)
            result[next_node] = result[node] + 1

print(*result)
