Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Two Paths

time limit per test

2 secondsmemory limit per test

64 megabytesinput

input.txtoutput

output.txtOnce archaeologists found *m* mysterious papers, each of which had a pair of integers written on them. Ancient people were known to like writing down the indexes of the roads they walked along, as «*a* *b*» or «*b* *a*», where *a*, *b* are the indexes of two different cities joint by the road . It is also known that the mysterious papers are pages of two travel journals (those days a new journal was written for every new journey).

During one journey the traveler could walk along one and the same road several times in one or several directions but in that case he wrote a new entry for each time in his journal. Besides, the archaeologists think that the direction the traveler took on a road had no effect upon the entry: the entry that looks like «*a* *b*» could refer to the road from *a* to *b* as well as to the road from *b* to *a*.

The archaeologists want to put the pages in the right order and reconstruct the two travel paths but unfortunately, they are bad at programming. That’s where you come in. Go help them!

Input

The first input line contains integer *m* (1 ≤ *m* ≤ 10000). Each of the following *m* lines describes one paper. Each description consists of two integers *a*, *b* (1 ≤ *a*, *b* ≤ 10000, *a* ≠ *b*).

Output

In the first line output the number *L*_{1}. That is the length of the first path, i.e. the amount of papers in its description. In the following line output *L*_{1} space-separated numbers — the indexes of the papers that describe the first path. In the third and fourth lines output similarly the length of the second path *L*_{2} and the path itself. Both paths must contain at least one road, i.e. condition *L*_{1} > 0 and *L*_{2} > 0 must be met. The papers are numbered from 1 to *m* according to the order of their appearance in the input file. The numbers should be output in the order in which the traveler passed the corresponding roads. If the answer is not unique, output any.

If it’s impossible to find such two paths, output «-1».

Don’t forget that each paper should be used exactly once, i.e *L*_{1} + *L*_{2} = *m*.

Examples

Input

2

4 5

4 3

Output

1

2

1

1

Input

1

1 2

Output

-1

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/30/2017 05:41:33 (c3).

Desktop version, switch to mobile version.
User lists

Name |
---|