Maximum Oddity

Time limit: 0.3s Memory limit: 256MB Input: Output:

Everything seems a bit odd these days! To embrace the oddness, we present you an odd challenge!.
You are given an undirected graph GG with NN vertices and MM edges. The graph is not necessarily connected.
Your task is to construct a spanning subgraph HH of GG such that the number of vertices with odd degree in HH is maximized.

Write a program that selects a subset of edges from GG (possibly all or none) to delete, such that the resulting graph HH spans all NN vertices and has the maximum possible number of vertices with odd degree.

Input data

The first line of the input contains NN and MM, the number of vertices and the number of edges in GG.

The next MM lines each contain a pair of integers Ui,ViU_i, V_i, describing the edges in the graph.

Output data

The first line of the output contains two integers:

  • XX, the maximum number of vertices with an odd degree in a spanning subgraph HH.
  • KK: the number of edges to be deleted from GG to obtain HH.

The next KK lines each contain a pair of integers: the endpoints of an edge (in arbitrary order) which you choose to delete.

If there are multiple solutions, you may print any correct one.

Constraints and clarifications

  • 1N1000001 \le N \le 100\,000.
  • 1M2000001 \le M \le 200\,000.
  • 1Ui,ViN1 \le U_i, V_i \le N and UiViU_i \neq V_i for each i=0M1i=0\ldots M - 1.
  • There is at most one edge between any pair of vertices.
  • A spanning subgraph of GG is a subgraph that includes all NN vertices of GG but may include only a subset of the edges. The resulting subgraph HH can have cycles, multiple components, or isolated vertices.
# Score Restrictions
0 0 Examples
1 7 N,M20N, M \le 20.
2 12 N,M1000N, M \le 1000.
3 14 The graph is a simple cycle.
4 16 The graph is a tree.
5 51 No additional limitations.

Example 1

stdin

4 3
1 2
2 4
4 1

stdout

2
1
4 2

Explanation

In the first sample case, the graph in the input is shown in the figure below.

The maximum number of odd vertices in a spanning subgraph HH is 22. We can remove any edge, or any pair of two edges to obtain such a subgraph.

Example 2

stdin

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

stdout

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

Log in or sign up to be able to send submissions!