#include <bits/stdc++.h>
using namespace std;
void dfs_orient(long long ind, set<long long> *g, set<long long> *tg,
                bool *vis) {
  vis[ind] = true;
  set<long long>::iterator it;
  for (it = g[ind].begin(); it != g[ind].end(); it++) {
    g[*it].erase(ind);
    tg[ind].erase(*it);
    if (!vis[*it]) dfs_orient(*it, g, tg, vis);
  }
}
void dfs_init_time(long long ind, set<long long> *g,
                   pair<long long, long long> *time, bool *vis, long long &t) {
  vis[ind] = true;
  time[ind].first = ++t;
  for (set<long long>::iterator it = g[ind].begin(); it != g[ind].end(); it++)
    if (!vis[*it]) dfs_init_time(*it, g, time, vis, t);
  time[ind].second = ++t;
}
inline bool cmp(const pair<long long, long long> &a,
                const pair<long long, long long> &b) {
  return (a.first == b.first ? a.second < b.second : a.first > b.first);
}
void dfs_visit(long long ind, set<long long> *g, bool *vis) {
  vis[ind] = true;
  for (set<long long>::iterator it = g[ind].begin(); it != g[ind].end(); it++)
    if (!vis[*it]) dfs_visit(*it, g, vis);
}
long long count_components(set<long long> *g, long long n, long long *topo) {
  bool vis[n];
  memset(vis, false, sizeof(vis));
  long long i, x = 0;
  for (i = 0; i < n; i++) {
    if (!vis[topo[i]]) {
      dfs_visit(topo[i], g, vis);
      ++x;
    }
  }
  return x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, i, u, v;
  cin >> n >> m;
  set<long long> g[n], tg[n];
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    --u, --v;
    g[u].insert(v);
    g[v].insert(u);
    tg[u].insert(v);
    tg[v].insert(u);
  }
  bool vis[n];
  memset(vis, false, sizeof(vis));
  dfs_orient(0, g, tg, vis);
  pair<long long, long long> time[n];
  memset(vis, false, sizeof(vis));
  long long t = 0;
  dfs_init_time(0, g, time, vis, t);
  long long topo_order[n];
  {
    pair<long long, long long> ftimes[n];
    for (i = 0; i < n; i++) {
      ftimes[i].first = time[i].second;
      ftimes[i].second = i;
    }
    sort(ftimes, ftimes + n, cmp);
    for (i = 0; i < n; i++) topo_order[i] = ftimes[i].second;
  }
  t = count_components(tg, n, topo_order);
  if (t != 1) {
    cout << 0;
    return 0;
  }
  for (i = 0; i < n; i++)
    for (set<long long>::iterator it = g[i].begin(); it != g[i].end(); it++)
      cout << i + 1 << " " << *it + 1 << "\n";
  return 0;
}
