#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

#define MAX_V 100000

int V, E;
vector<int> G[MAX_V];
vector<pair<int, int> > bridge;
bool visited[MAX_V];
int prenum[MAX_V];
int parent[MAX_V];
int lowest[MAX_V];
int timer, root;

void add_edge(int from, int to) {
  G[from].push_back(to);
  G[to].push_back(from);
}

void dfs(int u, int prev) {
    prenum[u] = timer;
    lowest[u] = timer;
    timer++;

    visited[u] = true;

    for(int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if(!visited[v]) {
        dfs(v, u);
        lowest[u] = min(lowest[u], lowest[v]);
        if(lowest[v] == prenum[v]) {
          if(u < v) bridge.push_back(make_pair(u, v));
          else bridge.push_back(make_pair(v, u));
        }
      } else if(v != prev) {
        lowest[u] = min(lowest[u], prenum[v]);
      }
    }

}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    add_edge(v1, v2);
  }

  for(int i = 0; i < V; i++) {
    visited[i] = false;
  }
  root = 0;
  timer = 1;
  dfs(root, -1);

  sort(bridge.begin(), bridge.end());
  for(int i = 0; i < bridge.size(); i++) {
    cout << bridge[i].first << " " << bridge[i].second << endl;
  }

}
### Prompt

Please provide a Cpp coded solution to the problem described below:

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

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;

#define MAX_V 100000

int V, E;
vector<int> G[MAX_V];
vector<pair<int, int> > bridge;
bool visited[MAX_V];
int prenum[MAX_V];
int parent[MAX_V];
int lowest[MAX_V];
int timer, root;

void add_edge(int from, int to) {
  G[from].push_back(to);
  G[to].push_back(from);
}

void dfs(int u, int prev) {
    prenum[u] = timer;
    lowest[u] = timer;
    timer++;

    visited[u] = true;

    for(int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if(!visited[v]) {
        dfs(v, u);
        lowest[u] = min(lowest[u], lowest[v]);
        if(lowest[v] == prenum[v]) {
          if(u < v) bridge.push_back(make_pair(u, v));
          else bridge.push_back(make_pair(v, u));
        }
      } else if(v != prev) {
        lowest[u] = min(lowest[u], prenum[v]);
      }
    }

}

int main () {
  cin >> V >> E;
  for(int i = 0; i < E; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    add_edge(v1, v2);
  }

  for(int i = 0; i < V; i++) {
    visited[i] = false;
  }
  root = 0;
  timer = 1;
  dfs(root, -1);

  sort(bridge.begin(), bridge.end());
  for(int i = 0; i < bridge.size(); i++) {
    cout << bridge[i].first << " " << bridge[i].second << endl;
  }

}
```