404694: GYM101611 E Empire History

Memory Limit:512 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Empire Historytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Long time ago, there were two great Kingdoms Someland and Otherland. Each of them consisted of at least two cities and some roads connecting them. It was possible to get from any city of any kingdom to any other city of this kingdom using only these roads. However, no two cities of different kingdoms were connected by a road.

As an old legend says, when both kingdoms were conquered by the Emperor of New Roads, he decided to unite them by doing what he was very well known for — by building new roads. He picked some non-empty subset of cities of Someland u1, u2, ..., uk and some non-empty subset of cities of Otherland v1, v2, ..., vl. Then, he ordered to build a new road between each pair of cities ux and vy (1 ≤ x ≤ k, 1 ≤ y ≤ l), thus adding k·l new roads.

Hundreds of years have passed. Since then, no new cities and no new roads were built, and no cities or roads were destroyed. However, no one actually remembers which cities were part of Someland and which cities were part of Otherland. This year, the empire plans to celebrate millennium, and you were hired to restore the historical truth and determine the possible division of cities between Someland and Otherland.

Input

The first line of the input contains two integers n and m (4 ≤ n ≤ 200 000, n - 1 ≤ m ≤ 200 000) — the number of cities and the number of roads in the current map of the empire.

Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the indices of cities connected by the i-th road. No road connects city with itself, and no two roads connect the same pair of cities.

Output

The first line of the output should contain two integers n1 and k (2 ≤ n1 ≤ n - 2, 1 ≤ k ≤ n1) — the number of cities in Someland and the number of cities of Someland selected by the Emperor of New Roads.

The second line should contain n1 distinct integers — indices of the cities of the empire that one day were part of Someland. First k of them should denote the subset selected for building new roads.

The third line should contain two integers n2 and l (n2 = n - n1, 1 ≤ l ≤ n2) — the number of cities in Otherland and the number of cities of Otherland selected to build the new roads.

The fourth line should list cities of Otherland in the same format as the cities of Someland.

In your solution, both Someland and Otherland should be connected. As no one really cares how these two kingdoms looked like, if there are several possible solutions, print any of them. It is guaranteed that at least one possible solution exists.

ExamplesInput
6 12
1 2
1 3
2 3
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
Output
4 4
3 4 5 6
2 2
1 2
Input
6 10
1 2
1 3
1 4
1 5
6 2
6 3
6 4
6 5
2 3
4 5
Output
2 2
4 5
4 2
1 6 2 3

加入题单

算法标签: