CF82C General Mobilization

Description

The Berland Kingdom is a set of $ n $ cities connected with each other with $ n-1 $ railways. Each road connects exactly two different cities. The capital is located in city $ 1 $ . For each city there is a way to get from there to the capital by rail. In the $ i $ -th city there is a soldier division number $ i $ , each division is characterized by a number of $ a_{i} $ . It represents the priority, the smaller the number, the higher the priority of this division. All values of $ a_{i} $ are different. One day the Berland King Berl Great declared a general mobilization, and for that, each division should arrive in the capital. Every day from every city except the capital a train departs. So there are exactly $ n-1 $ departing trains each day. Each train moves toward the capital and finishes movement on the opposite endpoint of the railway on the next day. It has some finite capacity of $ c_{j} $ , expressed in the maximum number of divisions, which this train can transport in one go. Each train moves in the direction of reducing the distance to the capital. So each train passes exactly one railway moving from a city to the neighboring (where it stops) toward the capital. In the first place among the divisions that are in the city, division with the smallest number of $ a_{i} $ get on the train, then with the next smallest and so on, until either the train is full or all the divisions are be loaded. So it is possible for a division to stay in a city for a several days. The duration of train's progress from one city to another is always equal to $ 1 $ day. All divisions start moving at the same time and end up in the capital, from where they don't go anywhere else any more. Each division moves along a simple path from its city to the capital, regardless of how much time this journey will take. Your goal is to find for each division, in how many days it will arrive to the capital of Berland. The countdown begins from day $ 0 $ .

Input Format

The first line contains the single integer $ n $ ( $ 1

Output Format

Print sequence $ t_{1},t_{2},...,t_{n} $ , where $ t_{i} $ stands for the number of days it takes for the division of city $ i $ to arrive to the capital. Separate numbers with spaces.