131_D. Subway
A subway scheme, classic for all Berland cities is represented by a set of n stations connected by n passages, each of which connects exactly two stations and does not pass through any others. Besides, in the classic scheme one can get from any station to any other one along the passages. The passages can be used to move in both directions. Between each pair of stations there is no more than one passage.

Berland mathematicians have recently proved a theorem that states that any classic scheme has a ringroad. There can be only one ringroad. In other words, in any classic scheme one can find the only scheme consisting of stations (where any two neighbouring ones are linked by a passage) and this cycle doesn't contain any station more than once.

This invention had a powerful social impact as now the stations could be compared according to their distance from the ringroad. For example, a citizen could say "I live in three passages from the ringroad" and another one could reply "you loser, I live in one passage from the ringroad". The Internet soon got filled with applications that promised to count the distance from the station to the ringroad (send a text message to a short number...).

The Berland government decided to put an end to these disturbances and start to control the situation. You are requested to write a program that can determine the remoteness from the ringroad for each station by the city subway scheme.

Input

The first line contains an integer n (3 ≤ n ≤ 3000), n is the number of stations (and trains at the same time) in the subway scheme. Then n lines contain descriptions of the trains, one per line. Each line contains a pair of integers xi, yi (1 ≤ xi, yi ≤ n) and represents the presence of a passage from station xi to station yi. The stations are numbered from 1 to n in an arbitrary order. It is guaranteed that xi ≠ yi and that no pair of stations contain more than one passage. The passages can be used to travel both ways. It is guaranteed that the given description represents a classic subway scheme.

Output

Print n numbers. Separate the numbers by spaces, the i-th one should be equal to the distance of the i-th station from the ringroad. For the ringroad stations print number 0.

Examples

Input

4
1 3
4 3
4 2
1 2


Output

0 0 0 0 

Input

6
1 2
3 4
6 4
2 3
1 3
3 5


Output

0 0 0 1 1 2 
```python
import sys
from collections import deque
sys.setrecursionlimit(30000)
sz = 3333
cyclic = 0
begin = 0
end = 0
cycle = []
graph = []
used = []
parent = []
dist = []

def dfs(current,prev):
    global graph,begin,end,used,parent
    used[current] = 1
    for nxt in graph[current]:
        if used[nxt] != 2 and nxt != prev:
            if used[nxt] == 0:
                parent[current] = nxt
                if dfs(nxt,current):
                    return True
            elif used[nxt] == 1:
                begin = current
                end = nxt
                return True
    used[current] = 2
    return False

def other_dfs(graph,current,cycle_in,d):
    used[current] = 1
    global dist
    dist[current] = (0 if (cycle_in[current]) else d)
    d = dist[current]
    for nxt in graph[current]:
        if not used[nxt]:
            other_dfs(graph,nxt,cycle_in,d + 1)

def main():
    n = int(input())
    global graph,used,parent,dist
    cycle = []
    graph = [[] for i in range(sz)]
    used = [0 for i in range(sz)]
    parent = [0 for i in range(sz)]
    dist = [0 for i in range(sz)]
    for i in range(n):
        x,y = [int(i) for i in input().split()]
        graph[x-1].append(y-1)
        graph[y-1].append(x-1)
    for i in range(n):
        if not used[i]:
            if dfs(i,-1):
                break
    u = end
    parent[begin] = -1
    while u != -1:
        cycle.append(u)
        u = parent[u]
    cycle_in = [False for i in range(n)]
    for node in cycle:
        cycle_in[node] = True
    used = [0 for i in range(n)]
    other_dfs(graph,begin,cycle_in,0)
    for node in dist[:n]:
        print(node,end = ' ')

if __name__ == "__main__":
    ##sys.stdin = open('oddoreven.in','r')
    ##sys.stdout = open('oddoreven.out','w')
    main()
    ##sys.stdin.close()
    ##sys.stdout.close()
```