#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edges;
vector<int> orientation;
vector<int> g[100000];
int v[100000], counter = 0;
int source = 0;
bool dfs(int gdzie, int parent) {
  if (v[gdzie] >= 0) {
    return true;
  }
  int initial = counter;
  v[gdzie] = counter++;
  for (int i = 0; i < g[gdzie].size(); i++) {
    if (orientation[g[gdzie][i]] == -1) {
      if (edges[g[gdzie][i]].first == gdzie) {
        orientation[g[gdzie][i]] = 2;
        if (!dfs(edges[g[gdzie][i]].second, gdzie)) return false;
      } else {
        orientation[g[gdzie][i]] = 1;
        if (!dfs(edges[g[gdzie][i]].first, gdzie)) return false;
      }
    }
    int edge = edges[g[gdzie][i]].first;
    if (edges[g[gdzie][i]].first == gdzie) {
      edge = edges[g[gdzie][i]].second;
    }
    if (edge != parent && v[edge] < v[gdzie]) {
      v[gdzie] = v[edge];
    }
  }
  return (parent == -1 || v[gdzie] < initial);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int skad, dokad;
    scanf("%d%d", &skad, &dokad);
    edges.push_back(make_pair(skad - 1, dokad - 1));
    orientation.push_back(-1);
    g[skad - 1].push_back(orientation.size() - 1);
    g[dokad - 1].push_back(orientation.size() - 1);
  }
  memset(v, -1, sizeof v);
  if (!dfs(0, -1)) {
    cout << "0" << endl;
  } else {
    for (int i = 0; i < m; i++) {
      if (orientation[i] == 1) {
        cout << edges[i].first + 1 << " " << edges[i].second + 1 << endl;
      } else {
        cout << edges[i].second + 1 << " " << edges[i].first + 1 << endl;
      }
    }
  }
  return 0;
}
