QOJ.ac

QOJ

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

#10673. Planning the Roadworks [A]

统计

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
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.