#P1656. 炸铁路

    ID: 641 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟搜索图论并查集洛谷原创最短路Tarjan

炸铁路

Description

Country A dispatches General uim to take strategic measures against Country B to rescue the suffering people.

Country B has nn cities connected by railways. Any two cities can be reached directly or indirectly via railways.

uim discovers that if a certain railway is destroyed, there will be a pair of cities that can no longer reach each other by railway. Such a railway is called a "key road."

To quickly paralyze the country's logistics system, uim hopes to blow up railways so that there exists a pair of cities that cannot reach each other.

However, there is only one shell (Country A's parliament will not fund more). So, which single railway can he bomb?

Input Format

The first line contains n,m (1n150, 1m5000)n, m\ (1 \leq n \leq 150,\ 1 \leq m \leq 5000), representing that there are nn cities and a total of mm railways.

The following mm lines each contain two integers a,ba, b, indicating that city aa and city bb are directly connected by a railway.

Output Format

Output several lines.

Each line contains two numbers a,ba, b, with a<ba < b, indicating that a,b\lang a,b\rang is a key road.

Please note: In the output, all pairs a,b\lang a,b\rang must be sorted by increasing aa; if aa is the same, then sort by increasing bb.

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

Hint

Translated by ChatGPT 5