#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long M = 3e5 + 5;
vector<long long> g[N];
map<pair<long long, long long>, long long> mp;
bool vis[N], sw[M];
long long dp[N];
set<long long> s;
void dfs(long long u, long long p) {
  vis[u] = 1;
  s.insert(u);
  for (auto v : g[u]) {
    if (!vis[v]) {
      if (!mp[{u, v}]) sw[mp[{v, u}]] = 1;
      dfs(v, u);
      dp[u] += dp[v];
    } else if (v != p) {
      if (s.count(v))
        dp[u]++;
      else {
        dp[u]--;
        if (!mp[{v, u}]) sw[mp[{u, v}]] = 1;
      }
    }
  }
  s.erase(u);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  pair<long long, long long> p[m + 1];
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    mp[{u, v}] = i;
    p[i] = {u, v};
  }
  dfs(1, 1);
  bool can = 1;
  for (long long i = 2; i <= n; i++)
    if (!dp[i]) can = 0;
  if (can)
    for (long long i = 1; i <= m; i++)
      if (sw[i])
        cout << p[i].second << " " << p[i].first << "\n";
      else
        cout << p[i].first << " " << p[i].second << "\n";
  else
    cout << 0;
  return 0;
}
