Hamilton

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Tracker Smurf is planning his trip for next holidays.  He wants to spend exactly one night in each of the villages in SmurfLand. His trip can start and end in any village.  Villages in SmurfLand are connected by roads in such a way that there's exactly one path between any two villages.  The distance between any two directly connected villages is exactly one kilometer.  Tracker is so fast that he can travel up to three kilometers each day, but he is still not sure if that's enough to be able to spend a night in each village exactly once.  Help him find the answer.

입력

First line of input contains an integer nn (1n1051 \leq n \leq 10^5) -- the number of villages in SmurfLand. The next n1n-1 lines describe the roads.  iith input line (i2,,ni \in \\{ 2, \ldots, n \\}) contains an integer p_ip\_i (1p_i<i1 \leq p\_i < i) which means that there is a road connecting villages ii and p_ip\_i.

출력

On a single line output nn integers q_1,q_2,,q_nq\_1, q\_2, \ldots, q\_n (1q_in1 \leq q\_i \leq n) specifying the sequence of villages for Tracker to spend the nights in (Tracker starts in village q_1q\_1 then goes to village q_2q\_2 and so on, finishing in village q_nq\_n). If it is not possible to plan Tracker's trip then on a single line output the word "NO" (without quotes).