Josh is a townplanner, and is in charge of the roads in his local village. The village contains
A road configuration is a set of
Currently, there is a road configuration
Due to a limited supply of gravel, he can only make operations in which he moves one road, by repeatedly deleting a road and adding another road. However, so that people can still travel around, all houses must be reachable from all other houses at all times. Specifically:
- He chooses a road from the current road configuration, and deletes it. After deletion, every house must still be reachable from every other house using the roads.
- Then, he adds a road between any two different houses that do not already have a road between them.
Can you help him achieve his goal? For full points, you must use as few operations as possible.
Note: it does not matter which road in
Constraints
No two houses have multiple roads between them in
Every house is reachable from every other house using only the roads in
Scoring
It can be proven that there always exists a sequence of operations transforming the road configuration from
To score any points, your solution must use at most
Input Specification
The first line contains a single integer,
The
The
Output Specification
On the first line, output an integer
On each of the next w x y z
, indicating that you will remove a road between houses
Sample Input
4
1 2
2 3
3 4
1 4
2 1
2 3
2 4
1 3
Sample Output
2
3 4 4 2
1 4 3 1
Comments