Problem: Find bridges of an undirected graph G(V, E).

A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.

Constraints

* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no parallel edges
* There are no self-loops

Input


|V| |E|
s0 t0
s1 t1
:
s|E|-1 t|E|-1


, where |V| is the number of nodes and |E| is the number of edges in the graph. The graph nodes are named with the numbers 0, 1,..., |V|-1 respectively.

si and ti represent source and target nodes of i-th edge (undirected).

Output

A list of bridges of the graph ordered by name. For each bridge, names of its end-ponints, source and target (source < target), should be printed separated by a space. The sources should be printed ascending order, then the target should also be printed ascending order for the same source.

Examples

Input

4 4
0 1
0 2
1 2
2 3


Output

2 3


Input

5 4
0 1
1 2
2 3
3 4


Output

0 1
1 2
2 3
3 4

Solution (in CPP):

Solution:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

typedef vector<vector<int> > Graph;
typedef pair<int, int> pii;
struct Node{
  int ord, low;
};

class BridgeFind{
public:
  BridgeFind(Graph _g){
    g = _g;
    node.resize(g.size(), Node{-1, (int)1e9});
  }
  vector<pii> find(){
    if(v_ord == 0)dfs();
    return bridge;
  }
private:
  void dfs(int v  = 0,
           int previous = -1){
    node[v].ord = node[v].low = v_ord++;
    int to;
    for (int i = 0; i < g[v].size(); i++) {
      to = g[v][i];
      if(previous == to)continue;
      if(node[to].ord == -1) dfs(to, v);
      node[v].low = min(node[v].low, node[to].low);
    }
    if(node[v].low == node[v].ord and previous != -1){
      if(previous > v)bridge.emplace_back(pii(v, previous)); 
      else bridge.emplace_back(pii(previous, v));      
    }

  }
  int v_ord = 0;
  vector<pii> bridge;
  Graph g;
  vector<Node> node;
};

int main(int argc, char *argv[]){
  int n, m;
  std::cin >> n >> m;
  Graph g(n, vector<int>());
  for (int i = 0; i < m; i++) {
    int to, from;
    std::cin >> to >> from;
    g[to].push_back(from);
    g[from].push_back(to);
  }
  BridgeFind bf(g);
  vector<pii> bridge = bf.find();
  sort(bridge.begin(), bridge.end());
  for (int i = 0; i < bridge.size(); i++) {
    std::cout << bridge[i].first << " " << bridge[i].second << std::endl;
  }
  // for (auto i: bridge){
  //   std::cout << i.first << " " << i.second << std::endl;
  // }
  return 0;
}