#P6379. [PA 2010] Planning the Roadworks

[PA 2010] Planning the Roadworks

Description

Given a directed graph with nn vertices and mm edges, find a set of edges such that after deleting this set, the reachability of the original graph remains unchanged (if a vertex was reachable before, it is still reachable), and furthermore, deleting any additional single edge will change the reachability of the original graph.

Please provide one feasible solution.

Input Format

The first line contains two integers nn, mm.

The next mm lines each contain two numbers x,yx, y, indicating that there is a directed edge from xx to yy.

Output Format

This problem uses Special Judge.

In the first line, output an integer kk, the size of the edge set.

In the next kk lines, output one integer eie_i per line, meaning you delete the eie_i-th edge in the input.

The input edges are numbered starting from 11.

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

Hint

Sample 1 Explanation

One feasible solution is to delete the 2nd input edge (1,3)(1, 3) and the 6th input edge (3,4)(3, 4).


Constraints

For all testdata, it is guaranteed that 1n50001 \le n \le 5000, 1m1000001 \le m \le 100000, and the given graph has no multiple edges or self-loops.

Translated by ChatGPT 5