Baku Metro#11865

Baku Metro

1 second
128 megabytes
Medium

The Baku Metro is one of the oldest and most unique in the region. The first line was opened in , and today the network includes dozens of stations, such as "28 May", "Icheri Sheher", "Nizami", and others. One of the distinctive features of the Baku metro is its deep, mosaic-decorated stations and the presence of transfer hubs. In recent years, there has been an active discussion about the construction of a circular line that would connect central and peripheral areas of the city.

As part of the capital's metro modernization project, an abstract model of the metro network was developed, consisting of stations and tunnels between them. Each tunnel connects exactly two stations and does not intersect any others. Moreover, it is possible to travel from any station to any other by moving along the tunnels. All tunnels are bidirectional, and there is at most one direct connection between any pair of stations.

Mathematicians in Baku have proven a theorem: in any such metro scheme, there exists exactly one cycle. In other words, a circular line can be found — a route passing through several stations, where any two neighboring stations are connected by a tunnel, and no station appears more than once.

This discovery caused a real sensation in the city: residents began to compare the distances of their stations to the circular line. One might say: "I live three transfers from the circle," while another boasts, "Only one for me." Mobile apps even appeared to calculate the distance of a station from the ring line (with a paid subscription, of course).

To take control of the situation, the Baku Metro Administration tasked you with developing a program that, given a map of the metro network, calculates for each station the minimum number of transfers needed to reach the circular line. For stations on the circular line, the distance is considered to be zero.

Input

The first line contains an integer n~(3 \le n \le 3000) — the number of stations in the metro network (which also equals the number of tunnels). The next lines each describe one tunnel. Each line contains a pair of integers x_i, y_i~(1 \le x_i, y_i \le n), indicating a tunnel between stations x_i and y_i.

Stations are numbered from to in arbitrary order.

It is guaranteed that x_i \ne y_i, there is at most one tunnel between any pair of stations, and all tunnels are bidirectional. It is also guaranteed that the given metro map is classical — that is, connected and contains exactly one cycle.

Output

Print integers: the -th number should represent the distance from the -th station to the circular line. For stations that are on the circular line, print .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading