QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 64 MB Total points: 10

#10673. Planning the Roadworks [A]

Statistics

A roadworks program has recently started in Bytetown. The inception of works has limited the traffic in the town, several streets have been closed. Some people claim that the access to some parts of the town has been completely cut off, however the lack of a coordinator of the roadworks makes a reliable verification of such information impossible.

To be able to control the situation, the mayor of Bytetown has given Byteman the position of the head of the Department of Computer-Assisted Roadworks Coordination. The roadworks that have already started cannot be stopped in the middle, however, the roadworks budget sill contains some funds with a strict spending deadline. That is why the mayor asked Byteman to prepare a list of streets that could additionally be closed (simultaneously) without further limiting the possibility of travelling in the town. In other words, if one junction is currently accessible from another junction then this property should remain after closing the streets contained in Byteman's list.

At first, Byteman was willing to find the largest such list, however he could not complete this task successfully. He, therefore, decided to find such a set of streets that cannot be extended by any other street without cutting off the access between any pair of junctions, for which the access currently exists. Write a program that will help Byteman prepare the requested list of streets.

Input Format

The first line of the standard input contains two integers $n$ and $m$ ($1 ≤ n ≤ 5\,000$, $1 ≤ m ≤ 100\,000$), denoting the number of junctions in the town and the number of unidirectional streets connecting them. The junctions are numbered from 1 to n. The following m lines contain the descriptions of respective streets; the i-th of these lines contains a description of the i-th street in a form of a pair of integers $a_{i}$, $b_{i}$ ($1 ≤ a_{i}, b_{i} ≤ n$, $a_{i} ≠ b_{i}$). Such a pair means that there exists a unidirectional street from junction $a_{i}$ to junction $b_{i}$. Each ordered pair will appear in the input at most once. The initial roadworks in the town have started without a proper preparation, so nothing should be assumed about the current shape of the road network.

Output Format

To the first line of the standard output your program should write one integer $k$ representing the number of streets in Byteman's list. The following $k$ lines should contain the numbers of streets that should be closed. The streets are numbered from 1 to m, according to the order from the input.

If there are multiple correct answers, output any one of them.

Example

Input

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

Output

2
2
6

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.