Under construction

Still being built. Things may change

Pipes

Interview

Time limit2sMemory limit32 MB

Summary
Find every pipe whose removal disconnects the spring network and print them sorted by endpoint numbers.
Level

Medium5 of 10

Topics
DFS, Graph
Solved
No attempts yet

Problem

In the land of the Cahoots, Lomikel is the god of pipes. He rules water pipes, drains, sewers, and perhaps subway tunnels as well. The Cahoots worship him at many sacred springs, and those springs are joined by a huge network of ceremonial pipes. One pipe joins two springs directly.

On every holiday the Supreme Plumber, the highest of Lomikel's priests, performs long rituals that move water through the pipes.

Lomikel's anger sometimes breaks a pipe, and then the Plumber has to send the water around the break through other pipes. For some pipes no other route exists. Such a pipe is called critical, and the Plumber watches it closely. The figure in the note draws the critical pipes in bold.

Read the description of the network and find every critical pipe. The network can be very large and the memory limit is tight, so store the network compactly.

Input

The first line contains the number of springs NN and the number of pipes MM, separated by a space (1≤N≤1000001 \le N \le 100000, 1≤M≤60000001 \le M \le 6000000).

Each of the next MM lines describes one pipe with two integers uu and vv separated by a space (1≤u,v≤N1 \le u, v \le N), the two springs that the pipe joins.

Several pipes can join the same pair of springs, but the two ends of one pipe are always different springs.

Output

Print one line for every critical pipe. The line holds the two springs of that pipe, the smaller number first, separated by a space.

Sort the lines by the first number, and by the second number when the first numbers are equal.

If no pipe is critical, print nothing.

Note

The pipes drawn in bold in the figure are the critical ones.

Examples2

  1. Example 1

    Input
    10 11
    1 7
    1 8
    1 6
    2 8
    6 7
    5 8
    2 5
    2 3
    2 4
    3 4
    10 9
    
    Expected output
    1 8
    9 10
    
  2. Example 2

    Input
    2 1
    1 2
    
    Expected output
    1 2