QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 256 MB Total points: 100

#13314. Multidrink

Statistics

Byteasar lives in Byteburg, a city famous for its milk bars on every corner. One day Byteasar came up with an idea of a "milk multidrink": he wants to visit each milk bar for a drink exactly once. Ideally, Byteasar would like to come up with a route such that the next bar is always no further than two blocks (precisely: intersections) away from the previous one.

The intersections in Byteburg are numbered from to , and all the streets are bidirectional. Between each pair of intersections there is a unique direct route, ie, one that does not visit any intersection twice. Byteasar begins at the intersection no. and finishes at the intersection no. .

Your task is to find any route that satisfies Byteasar's requirements if such a route exists.

problem_13314_1.gif

An exemplary route satisfying the requirements is: 1,11,8,7,5,9,2,10,4,6,3,12.

problem_13314_2.gif

There is no route that satisfies the requirements.

Input Format

In the first line of the standard input there is a single integer $n$ ($2 ≤ n ≤ 500\,000$), denoting the number of intersections in Byteburg. Each of the following $n-1$ lines holds a pair of distinct integers $a_{i}$ and $b_{i}$ ($1 ≤ a_{i},b_{i} ≤ n$), separated by a single space, that represent the street linking the intersections no. $a_{i}$ and $b_{i}$.

Output Format

If there is no route satisfying Byteasar's requirements, your program should print a single word "BRAK" (Polish for none), without the quotation marks to the standard output. Otherwise, your program should print $n$ lines to the standard output, the i-th of which should contain the number of the i-th intersection on an arbitrary route satisfying Byteasar's requirements. Obviously, in that case the first line should hold the number $1$, and the $n$-th line - number $n$.

Example

Input

12
1 7
7 8
7 11
7 2
2 4
4 10
2 5
5 9
2 6
3 6
3 12

Output

1
11
8
7
4
10
2
9
5
6
3
12

Input 2

15
1 14
14 7
7 8
7 11
7 2
2 4
4 10
2 5
5 9
2 6
3 6
3 15
11 12
8 13

Output 2

BRAK
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.