#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
int n, m;
namespace flow {
int n, s, t;
int head[200306], to[200306 << 1], nex[200306 << 1], wto[200306 << 1], ecn = 1;
int ade(int u, int v, int w) {
  to[++ecn] = v, nex[ecn] = head[u], wto[ecn] = w, head[u] = ecn;
  to[++ecn] = u, nex[ecn] = head[v], wto[ecn] = 0, head[v] = ecn;
  return ecn;
}
queue<int> Q;
int dep[200306], cur[200306];
const int inf = 1e9;
void clear() {
  for (int i = (1), iend = (n); i <= iend; ++i) head[i] = dep[i] = cur[i] = 0;
  ecn = 1;
}
bool bfs() {
  Q.push(s);
  for (int i = (1), iend = (n); i <= iend; ++i) cur[i] = head[i];
  memset(dep, 0x3f, sizeof dep);
  dep[s] = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = head[u]; i; i = nex[i])
      if (dep[to[i]] > inf && wto[i]) dep[to[i]] = dep[u] + 1, Q.push(to[i]);
  }
  return dep[t] < inf;
}
long long dfs(int u, long long lim) {
  if (!lim || u == t) return lim;
  long long flow = 0, f;
  for (int& i = cur[u]; i; i = nex[i])
    if (dep[to[i]] == dep[u] + 1 && (f = dfs(to[i], min(lim, 1ll * wto[i])))) {
      lim -= f, flow += f, wto[i] -= f, wto[i ^ 1] += f;
      if (!lim) break;
    }
  return flow;
}
long long dinic() {
  long long res = 0;
  while (bfs()) res += dfs(s, 0x3f3f3f3f3f3f3f3f);
  return res;
}
}  // namespace flow
pair<int, int> ed[200306];
int bc[200306];
long long chk(int x) {
  for (int i = (1), iend = (n); i <= iend; ++i) flow::ade(n + m + 1, i, x);
  for (int i = (1), iend = (m); i <= iend; ++i) {
    int u = ed[i].first, v = ed[i].second;
    bc[i] = flow::ade(u, i + n, 1);
    flow::ade(v, i + n, 1);
    flow::ade(i + n, n + m + 2, 1);
  }
  long long as = flow::dinic();
  flow::clear();
  return as;
}
void solve() {
  cin >> n >> m;
  for (int i = (1), iend = (m); i <= iend; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    ed[i] = make_pair(u, v);
  }
  int l = 0, r = n;
  flow::s = n + m + 1, flow::t = n + m + 2, flow::n = n + m + 2;
  while (l <= r) {
    int mid = l + r >> 1;
    long long as = chk(mid);
    if (as == m) {
      r = mid - 1;
    } else
      l = mid + 1;
  }
  cout << l << endl;
  chk(l);
  for (int i = (1), iend = (m); i <= iend; ++i) {
    int u = ed[i].first, v = ed[i].second;
    if (flow::wto[bc[i]])
      printf("%d %d\n", u, v);
    else
      printf("%d %d\n", v, u);
  }
}
signed main() { solve(); }
