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

using UnweightedGraph = vector<vector<int>>;
struct LowLink {
    const UnweightedGraph &g;
    vector<int> aps;                // articulation points
    vector<pair<int, int>> brs;     // brides
    vector<int> seen, ord, low;
    LowLink(const UnweightedGraph &g) : g(g) { }
    int dfs(int u, int p = -1, int time = 0) {
        seen[u] = true;
        ord[u] = low[u] = time++;
        bool exists = false;
        int cnt_ch = 0;
        for (auto v : g[u]) {
            if (!seen[v]) {
                ++cnt_ch;
                time = dfs(v, u, time);
                low[u] = min(low[u], low[v]);   // forward edge
                if (ord[u] < low[v]) brs.emplace_back(u, v);
                if (ord[u] <= low[v]) exists = true;
            } else if (v != p) {
                low[u] = min(low[u], ord[v]);   // back edge
            }
        }
        if ((p == -1 && cnt_ch > 1) || (p != -1 && exists)) {
            aps.emplace_back(u);
        }
        return time;
    }
    void build() {
        int N = g.size();
        seen.assign(N, 0); ord.resize(N); low.resize(N);
        aps.clear(); brs.clear();
        for (int v = 0; v < N; ++v) if (!seen[v]) dfs(v);
        for (auto &br: brs) if (br.first > br.second) swap(br.first, br.second);
        sort(brs.begin(), brs.end());
        sort(aps.begin(), aps.end());
    }
};

int main() {
    int V, E; cin >> V >> E;
    UnweightedGraph g(V);
    while (E--) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
        g[t].emplace_back(s);
    }
    LowLink ll(g);
    ll.build();
    //for (auto v: ll.aps) cout << v << endl;
    for (auto b: ll.brs) cout << b.first << " " << b.second << endl;
    return 0;
}

### Prompt

Please formulate a CPP solution to the following 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

### Response

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

using UnweightedGraph = vector<vector<int>>;
struct LowLink {
    const UnweightedGraph &g;
    vector<int> aps;                // articulation points
    vector<pair<int, int>> brs;     // brides
    vector<int> seen, ord, low;
    LowLink(const UnweightedGraph &g) : g(g) { }
    int dfs(int u, int p = -1, int time = 0) {
        seen[u] = true;
        ord[u] = low[u] = time++;
        bool exists = false;
        int cnt_ch = 0;
        for (auto v : g[u]) {
            if (!seen[v]) {
                ++cnt_ch;
                time = dfs(v, u, time);
                low[u] = min(low[u], low[v]);   // forward edge
                if (ord[u] < low[v]) brs.emplace_back(u, v);
                if (ord[u] <= low[v]) exists = true;
            } else if (v != p) {
                low[u] = min(low[u], ord[v]);   // back edge
            }
        }
        if ((p == -1 && cnt_ch > 1) || (p != -1 && exists)) {
            aps.emplace_back(u);
        }
        return time;
    }
    void build() {
        int N = g.size();
        seen.assign(N, 0); ord.resize(N); low.resize(N);
        aps.clear(); brs.clear();
        for (int v = 0; v < N; ++v) if (!seen[v]) dfs(v);
        for (auto &br: brs) if (br.first > br.second) swap(br.first, br.second);
        sort(brs.begin(), brs.end());
        sort(aps.begin(), aps.end());
    }
};

int main() {
    int V, E; cin >> V >> E;
    UnweightedGraph g(V);
    while (E--) {
        int s, t; cin >> s >> t;
        g[s].emplace_back(t);
        g[t].emplace_back(s);
    }
    LowLink ll(g);
    ll.build();
    //for (auto v: ll.aps) cout << v << endl;
    for (auto b: ll.brs) cout << b.first << " " << b.second << endl;
    return 0;
}

```