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 <bits/stdc++.h>

int v, e;
struct Edge {
  Edge() : isBridge(true) {}
  Edge(int src_, int dest_) : src(src_), dest(dest_), isBridge(true) {}
  int src;
  int dest;
  bool isBridge;
};
std::vector<Edge> graph[112345];

void load() {
  scanf("%d %d", &v, &e);
  for(int i = 0; i < e; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    graph[a].push_back(Edge(a, b));
    graph[b].push_back(Edge(b, a));
  }
}

int dfi[112345];
int parent[112345];
int dfiid = 1;
std::vector<int> backEdges[112345];
std::vector<int> ascNodes;

void dfs(int i, int prev) {
  dfi[i] = dfiid;
  dfiid += 1;
  ascNodes.push_back(i);
  for(Edge edge : graph[i]) {
    int src = edge.src;
    int dest = edge.dest;
    if( dest == prev ) continue;
    if( dfi[dest] == 0 ) {
      dfs(dest, src);
      parent[dest] = src;
    }
    else {
      // backEdge
      backEdges[dest].push_back(src);
      // printf("backEdge %d %d\n", src, dest);
    }
  }
}

bool visited[112345];
bool traversed[112345];
void traverse(int id) {
  if( visited[id] ) return;
  visited[id] = true;
  traversed[id] = true;
  traverse(parent[id]);
}
void calcChains() {
  for(int id : ascNodes) {
    visited[id] = true;
    for(int parent : backEdges[id]) {
      traverse(parent);
    }
  }
}

int main() {
  load();
  parent[0] = -1;
  dfs(0, -1);
  // for(int i = 0; i < v; ++i) {
  //   printf("(v, parent, dfi) = (%d, %d, %d)\n", i, parent[i], dfi[i]);
  // }
  calcChains();
  std::vector<std::pair<int, int>> res;
  for(int i = 0 + 1; i < v; ++i) {
    if( not traversed[i] ) {
      res.push_back(std::make_pair(std::min(i, parent[i]), std::max(i, parent[i])));
    }
  }
  std::sort(res.begin(), res.end());
  for(std::pair<int, int> st : res) {
    printf("%d %d\n", st.first, st.second);
  }

  return 0;
}