#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
const int M = 2e6 + 8;
const int N = 5e5 + 7;
const int inf = 1e9 + 7;
struct cow {
  int v, w, next;
} E[M];
int head[N], cur[N];
int deep[N], gap[N];
int nn, n, m, s, t;
int tot = 1;
void add(int u, int v, int w) {
  E[++tot].v = v;
  E[tot].w = w;
  E[tot].next = head[u];
  head[u] = tot;
  E[++tot].v = u;
  E[tot].w = 0;
  E[tot].next = head[v];
  head[v] = tot;
}
int d[N];
void clear() {
  memset(head, 0, sizeof head);
  memset(d, 0, sizeof d);
  tot = 1;
}
queue<int> Q;
void ins(int s, int t) {
  for (int i = 1; i <= nn; i++) {
    cur[i] = head[i];
    deep[i] = gap[i] = 0;
  }
  Q.push(t);
  deep[t] = 1;
  gap[1]++;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = head[u]; i; i = E[i].next) {
      int v = E[i].v;
      if (!deep[v]) {
        deep[v] = deep[u] + 1;
        gap[deep[v]]++;
        Q.push(v);
      }
    }
  }
}
int dfs(int u, int s, int t, int flow) {
  if (u == t) return flow;
  int flowed = 0;
  for (int &i = cur[u]; i; i = E[i].next) {
    int v = E[i].v;
    if (deep[u] == deep[v] + 1) {
      int tmp = dfs(v, s, t, min(flow, E[i].w));
      flow -= tmp;
      flowed += tmp;
      E[i].w -= tmp;
      E[i ^ 1].w += tmp;
      if (!flow) return flowed;
    }
  }
  gap[deep[u]]--;
  if (!gap[deep[u]]) deep[s] = nn + 1;
  deep[u]++;
  gap[deep[u]]++;
  cur[u] = head[u];
  return flowed;
}
int ISAP(int s, int t) {
  ins(s, t);
  int ret = dfs(s, s, t, inf);
  while (deep[s] <= nn) ret += dfs(s, s, t, inf);
  return ret;
}
int x[N], y[N], turn[N];
bool check(int lim) {
  clear();
  for (int i = 1; i <= n; i++) add(i, t, lim);
  for (int i = 1; i <= m; i++) {
    add(s, i + n, 1);
    add(i + n, x[i], 1);
    turn[i] = tot;
    add(i + n, y[i], 1);
  }
  if (ISAP(s, t) == m)
    return 1;
  else
    return 0;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    x[i] = read();
    y[i] = read();
  }
  s = n + m + 1;
  t = s + 1;
  nn = t;
  int l = 0, r = m;
  while (r - l > 5) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  for (int i = l; i <= r; i++) {
    if (check(i)) {
      printf("%d\n", i);
      break;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (E[turn[i]].w)
      printf("%d %d\n", x[i], y[i]);
    else
      printf("%d %d\n", y[i], x[i]);
  }
  return 0;
}
