CSES - E4590 2020 2 - Densest subgraph
  • Time limit: 3.00 s
  • Memory limit: 512 MB

Let G=(V,E)G = (V,E) be a simple, undirected graph; here VV is the set of nodes and EE is the set of edges.

The density of graph GG is m/nm/n, where mm is the number of edges and nn is the number of nodes.

We define an induced subgraph as follows. Let XVX \subseteq V be a nonempty subset of nodes. Then the subgraph induced by XX, in notation G[X]G[X], is formed by deleting all nodes that are not in XX. Naturally, whenever you delete a node, you will have to delete all edges connected to it as well.

Given a graph G=(V,E)G = (V,E), your task is to find a set XVX \subseteq V such that the density of G[X]G[X] is as large as possible. We say that G[X]G[X] is a densest subgraph of GG.

Let us look at a simple example. Consider a graph GG with the set of nodes V={1,2,3,4,5}V = \{1,2,3,4,5\} and that contains the edges {1,2}\{1,2\}, {2,3}\{2,3\}, {2,4}\{2,4\}, {3,4}\{3,4\}, {2,5}\{2,5\}, and {3,5}\{3,5\}. Now the density of GG is 6/56/5. If you select e.g. X={1,2}X = \{1,2\}, you will have a subgraph G[X]G[X] with only 11 edge and 22 nodes, so the density of G[X]G[X] is only 1/21/2; this is clearly a bad choice. However, if you select X={2,3,4,5}X = \{2,3,4,5\}, then you will have a subgraph G[X]G[X] with 55 edges and 44 nodes; the density of G[X]G[X] is 5/45/4. This is the best possible choice in this case; there is no induced subgraph with a higher density.

Input

The first line contains two numbers, nn and mm. This indicates that the input graph GG contains nn nodes and mm edges. The nodes are labelled V={1,2,,n}V = \{1,2,\dotsc,n\}.

Then there are mm lines that list the edges. On each line there are two numbers, uu and vv, with uvu \ne v and 1u,vn1 \le u,v \le n. This indicates that there is an edge {u,v}E\{u,v\} \in E, that is, there is an undirected edge between the nodes uu and vv in graph GG. Each edge is listed only once.

Output

Output a description of a densest subgraph G[X]G[X]. First, output a line with two numbers, nn' and mm', where n=Xn' = |X| is the number of nodes in G[X]G[X] and mm' is the number of edges in G[X]G[X].

Then output one line with nn numbers: the labels of the nodes that are contained in subset XX.

If there are multiple equally dense subgraphs, you can output any such solution.

Limits

  • 2n1002 \le n \le 100
  • 1mmin(500,n(n1)2)1 \le m \le \min(500, \frac{n(n-1)}{2})

Example

Input:

5 6
1 2
2 3
2 4
3 4
2 5
3 5

Output:

4 5
2 3 4 5

Picture of the example:

The nodes in the output and edges connecting them have been marked with red.