QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 16 MB 満点: 100

#8376. Bridge

統計

Given an undirected graph with $n$ vertices and $m$ edges, find all bridges in the graph. A bridge is an edge whose removal increases the number of connected components of the graph.

Input

The first line contains two positive integers $n$ and $m$, representing the number of vertices and edges in the graph, respectively.

The next $m$ lines each contain two non-negative integers $u$ and $v$, representing an edge between $u$ and $v$. It is guaranteed that $1 \le u, v \le n$.

Output

Output all bridges found in the graph. Each bridge should be printed on a new line as two positive integers representing the two endpoints of the edge.

Subtasks

Subtask $N \le$ $M \le$
1 100 200
2 5000 15000
3 4000 60000
4 10000 1200000
5 30000 1500000
6 70000 2000000
7 80000 3000000
8 100000 4000000
9 100000 5000000
10 100000 6000000

Each subtask is worth 10 points.

Examples

Input 1

10 11
1 7
1 8
1 6
2 8
6 7
5 8
2 5
2 3
2 4
3 4
10 9

Output 1

1 8
9 10

Discussions

About Discussions

The discussion section is only for posting: 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.
  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.