#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9, MAX2 = 3e5 + 9;
const long long MOD = 1e9 + 7;
vector<pair<int, int> > g[MAX];
pair<int, int> e[MAX2];
int h[MAX], mark[MAX2], dp[MAX], par[MAX];
bool vis[MAX];
void dfs(int v, int height) {
  vis[v] = true;
  h[v] = height;
  for (auto x : g[v]) {
    int u = x.first;
    if (!vis[u]) {
      mark[x.second] = true;
      par[u] = v;
      dfs(u, height + 1);
    }
  }
}
void dfs2(int v) {
  dp[v] = h[v];
  bool f = false;
  if (v == 2) f = true;
  for (auto x : g[v]) {
    int u = x.first;
    if (mark[x.second]) {
      if (par[u] == v) {
        dfs2(u);
        dp[v] = min(dp[v], dp[u]);
      }
      continue;
    }
    dp[v] = min(dp[v], h[u]);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(par, -1, sizeof(par));
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--, u--;
    g[v].push_back({u, i});
    g[u].push_back({v, i});
    e[i] = {v, u};
  }
  memset(vis, 0, sizeof(vis));
  dfs(0, 0);
  dfs2(0);
  for (int i = 0; i < m; i++) {
    if (!mark[i]) continue;
    int v = e[i].first, u = e[i].second;
    if (v != par[u]) swap(v, u);
    if (dp[u] > h[v]) return cout << "0\n", 0;
  }
  for (int i = 0; i < m; i++) {
    int v = e[i].first, u = e[i].second;
    if (mark[i]) {
      if (v != par[u]) swap(v, u);
    } else {
      if (h[v] < h[u]) swap(v, u);
    }
    cout << v + 1 << " " << u + 1 << "\n";
  }
}
