#include <iostream>
#include <vector>
#include <forward_list>
#include <utility>
#include <algorithm>
#include <cstdio>

using namespace std;

#define MAX 100000

int cnt;
int pre[MAX];
int low[MAX];
vector<pair<int,int>> ans;

class EDGE{
public:
    int v;
    int w;
    EDGE(int vin,int win):v(vin),w(win){;}
};

class Graph{
public:
    int V;
    int E;
    vector<forward_list<int>> adj_list;
    void addedge(int v,int w);
    void BridgeR(EDGE e);
    Graph(int v,int e):V(v),E(e){adj_list.resize(v);}
};

void Graph::addedge(int v,int w){
    adj_list[v].push_front(w);
    adj_list[w].push_front(v);
}

void Graph::BridgeR(EDGE e){
    pre[e.w] = cnt++;
    low[e.w] = pre[e.w];
    int t;
    for(auto n = adj_list[e.w].cbegin();n != adj_list[e.w].cend();++n){
        t = *n;
        if(pre[t] == -1){
            BridgeR(EDGE(e.w,t));
            if(low[t] < low[e.w]) low[e.w] = low[t];
            if(low[t] == pre[t]) {
                if(t > e.w) ans.push_back(make_pair(e.w,t));
                else ans.push_back(make_pair(t,e.w));
            }
        }
        else if(t != e.v){
            low[e.w] = min(pre[t],low[e.w]);
        }
    }
}

void solution(Graph &G){
    cnt = 0;
    for(int i = 0; i < G.V;i++){
        if(pre[i] == -1){
            G.BridgeR(EDGE(i,i));
        }
    }
}

int main(){
    int V,E,s,t;
    scanf("%d %d",&V,&E);
    Graph G(V,E);
    for(int i = 0; i < E;i++){
        scanf("%d %d",&s,&t);
        G.addedge(s,t);
    }

    for(int i = 0;i < V;i++){
        pre[i] = -1;
        low[i] = -1;
    }

    solution(G);
    sort(ans.begin(),ans.end());
    for(auto &a:ans){
        printf("%d %d\n",a.first,a.second);
    }
}


### Prompt

Construct a CPP code solution to the problem outlined:

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 <vector>
#include <forward_list>
#include <utility>
#include <algorithm>
#include <cstdio>

using namespace std;

#define MAX 100000

int cnt;
int pre[MAX];
int low[MAX];
vector<pair<int,int>> ans;

class EDGE{
public:
    int v;
    int w;
    EDGE(int vin,int win):v(vin),w(win){;}
};

class Graph{
public:
    int V;
    int E;
    vector<forward_list<int>> adj_list;
    void addedge(int v,int w);
    void BridgeR(EDGE e);
    Graph(int v,int e):V(v),E(e){adj_list.resize(v);}
};

void Graph::addedge(int v,int w){
    adj_list[v].push_front(w);
    adj_list[w].push_front(v);
}

void Graph::BridgeR(EDGE e){
    pre[e.w] = cnt++;
    low[e.w] = pre[e.w];
    int t;
    for(auto n = adj_list[e.w].cbegin();n != adj_list[e.w].cend();++n){
        t = *n;
        if(pre[t] == -1){
            BridgeR(EDGE(e.w,t));
            if(low[t] < low[e.w]) low[e.w] = low[t];
            if(low[t] == pre[t]) {
                if(t > e.w) ans.push_back(make_pair(e.w,t));
                else ans.push_back(make_pair(t,e.w));
            }
        }
        else if(t != e.v){
            low[e.w] = min(pre[t],low[e.w]);
        }
    }
}

void solution(Graph &G){
    cnt = 0;
    for(int i = 0; i < G.V;i++){
        if(pre[i] == -1){
            G.BridgeR(EDGE(i,i));
        }
    }
}

int main(){
    int V,E,s,t;
    scanf("%d %d",&V,&E);
    Graph G(V,E);
    for(int i = 0; i < E;i++){
        scanf("%d %d",&s,&t);
        G.addedge(s,t);
    }

    for(int i = 0;i < V;i++){
        pre[i] = -1;
        low[i] = -1;
    }

    solution(G);
    sort(ans.begin(),ans.end());
    for(auto &a:ans){
        printf("%d %d\n",a.first,a.second);
    }
}


```