#include <bits/stdc++.h>
using namespace std;
struct Maxflow {
  static const int oo = 100000005;
  static const int maxn = 5555 * 2;
  static const int maxm = 5555 * 4;
  int T, S;
  struct node {
    int to, nxt, cap;
  } ed[maxm * 2];
  int head[maxn], cur[maxn], cnt, ans, ndnum;
  int h[maxn];
  void addedge(int u, int v, int cap) {
    ed[cnt].to = v, ed[cnt].cap = cap, ed[cnt].nxt = head[u], head[u] = cnt++;
    ed[cnt].to = u, ed[cnt].cap = 0, ed[cnt].nxt = head[v], head[v] = cnt++;
  }
  bool bfs() {
    memset(h, -1, sizeof(h));
    queue<int> q;
    h[S] = 0, q.push(S);
    while (!q.empty()) {
      int now = q.front();
      q.pop();
      for (int i = head[now]; ~i; i = ed[i].nxt) {
        if (ed[i].cap && h[ed[i].to] == -1) {
          h[ed[i].to] = h[now] + 1;
          q.push(ed[i].to);
        }
      }
    }
    return h[T] != -1;
  }
  int dfs(int x, int f) {
    if (x == T || f == 0) return f;
    int w, used = 0;
    for (int i = cur[x]; ~i; i = ed[i].nxt) {
      if (h[ed[i].to] == h[x] + 1) {
        w = f - used;
        w = dfs(ed[i].to, min(w, ed[i].cap));
        ed[i].cap -= w;
        ed[i ^ 1].cap += w;
        if (ed[i].cap) cur[x] = i;
        used += w;
        if (used == f) return f;
      }
    }
    if (!used) h[x] = -1;
    return used;
  }
  void dinic() {
    while (bfs()) {
      for (int i = 1; i <= ndnum; i++) {
        cur[i] = head[i];
      }
      ans += dfs(S, oo);
    }
  }
  void init(int s, int t, int num) {
    for (int i = 1; i <= num; i++) head[i] = -1;
    ans = cnt = 0;
    T = t;
    S = s;
    ndnum = num;
  }
} flow;
int n, m;
int a[5111], b[5111];
bool isok(int x) {
  flow.init(n + m + 1, n + m + 3, n + m + 3);
  int s = n + m + 1, t = n + m + 2, T = n + m + 3;
  for (int i = 1; i <= m; i++) {
    flow.addedge(i, m + a[i], 1);
    flow.addedge(i, m + b[i], 1);
  }
  for (int i = 1; i <= m; i++) flow.addedge(s, i, 1);
  for (int i = 1; i <= n; i++) flow.addedge(m + i, t, x);
  flow.addedge(t, T, m);
  flow.dinic();
  return flow.ans == m;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &a[i], &b[i]);
  int l = 0, r = m, ans = m;
  while (l <= r) {
    int mid = l + r >> 1;
    if (isok(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%d\n", ans);
  isok(ans);
  for (int i = 0; i < 4 * m; i += 4) {
    if (flow.ed[i].cap == 1)
      printf("%d %d\n", b[i / 4 + 1], a[i / 4 + 1]);
    else
      printf("%d %d\n", a[i / 4 + 1], b[i / 4 + 1]);
  }
  return 0;
}
