#include <bits/stdc++.h>
using namespace std;
const int M = 5e5 + 5;
int n, m, a, b;
vector<pair<int, int>> v[M];
pair<int, int> out[M];
int low[M], in[M], idx;
void dfs(int u, int p) {
  low[u] = in[u] = ++idx;
  for (auto r : v[u]) {
    int x = r.first;
    int id = r.second;
    if (x == p) continue;
    if (!out[id].first) {
      out[id] = {u, x};
    }
    if (!low[x]) {
      dfs(x, u);
      if (in[u] < low[x]) {
        puts("0");
        exit(0);
      }
      low[u] = min(low[x], low[u]);
    } else
      low[u] = min(in[x], low[u]);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &a, &b);
    v[a].push_back({b, i});
    v[b].push_back({a, i});
  }
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    printf("%d %d\n", out[i].first, out[i].second);
  }
}
