QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 192 MB Total points: 100

#13178. Station

統計

The first stage of train system reform (that has been described in the problem Railways of the third stage of 14th Polish OI. However, one needs not be familiar with that problem in order to solve this task.) has come to an end in Byteotia. The system consists of bidirectional segments of tracks that connect railway stations. No two stations are (directly) connected by more than one segment of tracks.

Furthermore, it is known that every railway station is reachable from every other station by a unique route. This route may consist of several segments of tracks, but it never leads through one station more than once.

The second stage of the reform aims at developing train connections. Byteasar count on your aid in this task. To make things easier, Byteasar has decided that:

  • one of the stations is to became a giant hub and receive the glorious name of Bitwise,
  • for every other station a connection to Bitwise and back is to be set up,
  • each train will travel between Bitwise and its other destination back and forth along the only possible route, stopping at each intermediate station.

It remains yet to decide which station should become Bitwise. It has been decided that the average cost of travel between two different stations should be minimal. In Byteotia there are only one-way-one-use tickets at the modest price of 1 bythaler, authorising the owner to travel along exactly one segment of tracks, no matter how long it is. Thus the cost of travel between any two stations is simply the minimum number of tracks segments one has to ride along to get from one stations to the other.

Write a programme that:

  • reads the description of the train system of Byteotia,
  • determines the station that should become Bitwise,
  • writes out the result to the standard output.

Input

The first line of the standard input contains one integer $n$ ($2 ≤ n ≤ 1\,000\,000$) denoting the number of the railway stations. The stations are numbered from $1$ to $n$. Stations are connected by $n-1$ segments of tracks. These are described in the following $n-1$ lines, one per line. Each of these lines contains two positive integers $a$ and $b$ ($1 ≤ a < b ≤ n$), separated by a single space and denoting the numbers of stations connected by this exact segment of tracks.

Output

In the first and only line of the standard output your programme should print out one integer - the optimum location of the Bitwise hub. If more than one optimum location exists, it may pick one of them arbitrarily.

Example

Input

8
1 4
5 6
4 5
6 7
6 8
2 4
3 4
problem_13178_1.gif

Output

7

The circles in the figure depict stations (the numbers inside are the numbers of stations), while edges represent segments of tracks. Optimum locations of the Bitwise hub are the stations no. 7 or 8. If one of them is chosen, the average cost of travel between a pair of different stations equals $\frac {36}{28} ≈ 1.2857$ (in the example there are 28 unordered pairs of stations).

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.