#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adj[300005];
int dp[300005], lvl[300005];
pair<int, int> ans[300005];
bool root_check;
void dfs(int u, int p) {
  for (auto e : adj[u]) {
    int v = e.first;
    int id = e.second;
    if (v == p) continue;
    if (lvl[v] == -1) {
      lvl[v] = lvl[u] + 1;
      dfs(v, u);
      ans[id] = {u, v};
      dp[u] += dp[v];
    } else {
      if (lvl[v] < lvl[u]) {
        dp[u]++;
        dp[v]--;
        if (v == 1) root_check = true;
        ans[id] = {u, v};
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back({v, i + 1});
    adj[v].push_back({u, i + 1});
  }
  for (int i = 1; i <= n; i++) lvl[i] = -1;
  lvl[1] = 0;
  dfs(1, 0);
  if (!root_check) {
    cout << 0 << '\n';
    return 0;
  }
  for (int i = 2; i <= n; i++) {
    if (dp[i] == 0) {
      cout << 0 << '\n';
      return 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i].first << " " << ans[i].second << '\n';
  }
  return 0;
}
