Two Choreographies

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

문제

Somin and Eunjoo are famous dancers and very talented choreographers, but they haven't won a contest recently. To win the contest this year, they are trying to help each other to make new choreographies. Actually, nobody has tried smoothly appending static motions, and they are going to give it a try for the first time!

Somin and Eunjoo want to make two choreographies consisting of nn static motions for each of them. They have a good understanding of how to smoothly append static motions, and they concluded that exactly 2n32n - 3 unordered pairs of static motions are enough for them to perform freely. The order of static motions in a pair A,B\\{A, B\\} does not matter, i.e., if motion BB can be appended after motion AA, then AA can also be appended after BB.

The choreographies which Somin and Eunjoo want to perform are as follows. The two choreographies last for the same amount of time, which means that each one should consist of the same number of static motions. Each choreography should end at its first static motion. More precisely, two choreographies C_1C\_1 and C_2C\_2 are sequences of distinct ll static motions, C_1=(a_0,a_1,,a_l)C\_1 = (a\_0, a\_1, \dots , a\_l) and C_2=(b_0,b_1,,b_l)C\_2 = (b\_0, b\_1, \dots , b\_l) where a_0=a_la\_0 = a\_l and b_0=b_lb\_0 = b\_l. For the entertainment of the audience, C_1C\_1 and C_2C\_2 should be different, that is, there should be some 0il10 ≤ i ≤ l - 1 which a_i,a_i+1\\{a\_i, a\_{i+1}\\} in C_1C\_1 is not equal to any of b_j,b_j+1\\{b\_j, b\_{j+1}\\} in C_2C\_2 for 0jl10 ≤ j ≤ l - 1. (For example, (1,2,3,4,5,1)(1,2,3,4,5,1) and (3,4,5,2,1,3)(3,4,5,2,1,3) are different but (1,2,3,4,5,1)(1,2,3,4,5,1) and (3,4,5,1,2,3)(3,4,5,1,2,3) are not.) Also, the audience easily gets bored, so the choreography should not be too short, and contain at least 33 distinct static motions, that is, l3l ≥ 3.

For this, you are given 2n32n - 3 unordered pairs PP of static motions from nn distinct static motions m_1,,m_nm\_1, \dots, m\_n that two dancers can perform. For a pair m_i,m_j\\{m\_i, m\_j\\} where iji ≠ j, one of m_im\_i and m_jm\_j can appear after the other in the sequence; there is no specific order between them. You should write a program to find two different choreographies C_1=(a_0,a_1,,a_l)C\_1 = (a\_0, a\_1, \dots , a\_l) and C_2=(b_0,b_1,,b_l)C\_2 = (b\_0, b\_1, \dots , b\_l) of the same length l3l ≥ 3 such that a_i,a_i+1P\\{a\_i, a\_{i+1}\\} ∈ P, b_i,b_i+1P\\{b\_i, b\_{i+1}\\} ∈ P for any 0il10 ≤ i ≤ l - 1, and a_0=a_la\_0 = a\_l and b_0=b_lb\_0 = b\_l.

입력

Your program is to read from standard input. The input starts with a line containing a single integer, nn (4n100,0004 ≤ n ≤ 100\\,000), where nn is the number of static motions two dancers can represent. Each static motion is numbered as an integer from 11 to nn. The following 2n32n - 3 lines represent 2n32n - 3 unordered pairs of stack motions, PP. Each line contains two distinct integers representing two static motions of a pair of PP. Note that no two pairs in PP are identical.

출력

Your program is to write to standard output. If you cannot find two choreographies of static motions, then print 1-1. If not, you should print exactly three lines. The first line contains an integer l3l ≥ 3 which is the number of distinct static motions in each choreography. The second line contains exactly ll integers, separated by a space, each representing a choreography of the ll static motions in order. The last repeated motion should be omitted. The third line contains exactly ll integers representing the other choreography