#include <bits/stdc++.h>
using namespace std;
class Graph {
 public:
  Graph(int n) {
    _N = n;
    _G = vector<vector<int>>(n, vector<int>());
    _cap = vector<vector<char>>(n, vector<char>(n, 0));
  }
  void setSource(int source) { _source = source; }
  void setDest(int dest) { _dest = dest; }
  void addEdge(int x, int y, int cap, int cost = 0) {
    if (_cap[x][y]) {
      _cap[x][y] += cap;
      return;
    }
    _G[x].push_back(y);
    _G[y].push_back(x);
    _cap[x][y] = cap;
  }
  bool augmentingPath(vector<int> &d, vector<int> &dad) {
    queue<int> Q;
    Q.push(_source);
    d[_source] = 0;
    dad[_source] = _source;
    while (!Q.empty()) {
      int node = Q.front();
      Q.pop();
      for (auto temp : _G[node]) {
        if (_cap[node][temp] <= 0) continue;
        if (d[temp] > d[node]) {
          dad[temp] = node;
          d[temp] = d[node];
          Q.push(temp);
          if (temp == _dest) return true;
        }
      }
    }
    return (dad[_dest] != -1);
  }
  pair<int, int> minCostMaxFlow() {
    vector<int> dad(_N, -1);
    vector<int> d(_N, _COST_INF);
    int flow = 0;
    int flowcost = 0;
    while (augmentingPath(d, dad)) {
      char first = 1;
      for (int node = _dest; node != _source; node = dad[node])
        first = min(char(first), _cap[dad[node]][node]);
      for (int node = _dest; node != _source; node = dad[node]) {
        _cap[dad[node]][node] -= first;
        _cap[node][dad[node]] += first;
      }
      flow += first;
      flowcost += d[_dest];
      dad = vector<int>(_N, -1);
      d = vector<int>(_N, _COST_INF);
    }
    return make_pair(flow, flowcost);
  }
  int _N;
  vector<vector<int>> _G;
  vector<vector<char>> _cap;
  int _source, _dest;
  static const int _CAP_INF = (1 << 30);
  static const int _COST_INF = 2e9 + 5;
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m, 0), b(m, 0);
  vector<vector<int>> g(n, vector<int>());
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    a[i] -= 1;
    b[i] -= 1;
    if (rand() % 2)
      g[a[i]].push_back(b[i]);
    else
      g[b[i]].push_back(a[i]);
  }
  int ans = 1e3;
  for (int it = 0; it < 10000; ++it) {
    int maxx = 0, who = -1;
    for (int i = 0; i < n; ++i) {
      if (int(g[i].size()) > maxx) {
        maxx = g[i].size();
        who = i;
      }
    }
    if (maxx == 0) {
      ans = 0;
      break;
    }
    ans = min(ans, maxx);
    random_shuffle(g[who].begin(), g[who].end());
    int where = g[who].back();
    g[who].pop_back();
    g[where].push_back(who);
  }
  int sol = -1;
  vector<pair<int, int>> ret;
  for (int lf = max(0, ans - 10), rt = ans; lf <= rt;) {
    int mid = (lf + rt) / 2;
    int NODES = m + n + 2;
    Graph G(NODES);
    G.setSource(m + n);
    G.setDest(m + n + 1);
    for (int i = 0; i < m; ++i) {
      G.addEdge(m + n, i, 1);
      G.addEdge(i, m + a[i], 1);
      G.addEdge(i, m + b[i], 1);
    }
    for (int i = 0; i < n; ++i) {
      G.addEdge(m + i, m + n + 1, mid);
    }
    auto ans = G.minCostMaxFlow();
    if (ans.first == m) {
      sol = mid;
      rt = mid - 1;
      vector<pair<int, int>> aux;
      for (int i = 0; i < m; ++i) {
        if (G._cap[i][m + a[i]] == 0) {
          aux.push_back(make_pair(a[i], b[i]));
        } else {
          aux.push_back(make_pair(b[i], a[i]));
        }
      }
      ret = aux;
    } else {
      lf = mid + 1;
    }
  }
  cout << sol << "\n";
  for (auto temp : ret)
    cout << temp.first + 1 << " " << temp.second + 1 << "\n";
}
