#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
    vector<UL> E[100000];
    UL P[100000];
    bool F[100000] = {};
    vector<pair<UL, UL>> ans;
    UL D[100000];

    UL DFS(UL p) {
        F[p] = true;
        UL tmp = D[p];
        for (UL e : E[p]) {
            if (P[p] == e) continue;
            if (F[e]) {
                tmp = min(tmp, D[e]);
            }
            else {
                P[e] = p;
                D[e] = D[p] + 1;
                UL res = DFS(e);
                if (res > D[p]) ans.push_back({ min(p, e), max(p, e) });
                tmp = min(tmp, res);
            }
        }
        return tmp;
    }

    void Solve() {
        UL N, M; scanf("%d%d", &N, &M);
        rep(i, M) {
            UL u, v; scanf("%d%d", &u, &v);
            if (u > v)swap(u, v);
            E[u].push_back(v);
            E[v].push_back(u);
        }
        D[0] = 0;
        DFS(0);
        sort(ans.begin(), ans.end());
        for (auto& a : ans) printf("%d %d\n", a.first, a.second);
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



### Prompt

Develop a solution in cpp 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<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
    vector<UL> E[100000];
    UL P[100000];
    bool F[100000] = {};
    vector<pair<UL, UL>> ans;
    UL D[100000];

    UL DFS(UL p) {
        F[p] = true;
        UL tmp = D[p];
        for (UL e : E[p]) {
            if (P[p] == e) continue;
            if (F[e]) {
                tmp = min(tmp, D[e]);
            }
            else {
                P[e] = p;
                D[e] = D[p] + 1;
                UL res = DFS(e);
                if (res > D[p]) ans.push_back({ min(p, e), max(p, e) });
                tmp = min(tmp, res);
            }
        }
        return tmp;
    }

    void Solve() {
        UL N, M; scanf("%d%d", &N, &M);
        rep(i, M) {
            UL u, v; scanf("%d%d", &u, &v);
            if (u > v)swap(u, v);
            E[u].push_back(v);
            E[v].push_back(u);
        }
        D[0] = 0;
        DFS(0);
        sort(ans.begin(), ans.end());
        for (auto& a : ans) printf("%d %d\n", a.first, a.second);
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



```