#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 9;
vector<pair<int, int> > g[MAX], edge;
vector<int> g2[MAX], tp, g3[MAX];
int n, m, a, b, c, ori[MAX];
bool mark[MAX];
void dfs(int v) {
  mark[v] = true;
  for (auto u : g[v])
    if (!mark[u.first])
      ori[u.second] = (make_pair(v, u.first) == edge[u.second]), dfs(u.first);
    else
      ori[u.second] = (make_pair(v, u.first) != edge[u.second]);
}
void dfs2(int v) {
  mark[v] = true;
  for (auto u : g2[v])
    if (!mark[u]) dfs2(u);
  tp.push_back(v);
}
void dfs3(int v) {
  mark[v] = true;
  for (auto u : g3[v])
    if (!mark[u]) dfs3(u);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> a >> b, a--, b--, g[a].push_back({b, i}), g[b].push_back({a, i}),
        edge.push_back({a, b});
  dfs(0);
  for (int i = 0; i < edge.size(); i++) {
    if (!ori[i]) swap(edge[i].first, edge[i].second);
    g2[edge[i].first].push_back(edge[i].second),
        g3[edge[i].second].push_back(edge[i].first);
  }
  memset(mark, 0, sizeof mark), dfs2(0), memset(mark, 0, sizeof mark),
      reverse(tp.begin(), tp.end());
  for (auto t : tp)
    if (!mark[t]) dfs3(t), c++;
  if (c > 1)
    cout << 0;
  else
    for (auto i : edge) cout << i.first + 1 << " " << i.second + 1 << '\n';
}
