#include <bits/stdc++.h>
using namespace std;

int n, m;
int a[100002][2];
vector <int> sp[1002];
vector <pair <int, int> > v;
bool used[5006];

bool obshto (int x, int y) {
    if (a[x][0] == a[y][0] or a[x][0] == a[y][1] or a[x][1] == a[y][0] or a[x][1] == a[y][1]) {return true;}
    return false;
}

bool speaks (int x, int y) {
    if (a[x][0] == y or a[x][1] == y) {return true;}
    return false;
}

int main () {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

cin >> n >> m;

for (int i=1; i <= m; i++) {
    cin >> a[i][0] >> a[i][1];
}

for (int i=1; i <= n; i++) {
    for (int j=1; j <= m; j++) {
        if (speaks (j, i) == true) {
            sp[i].push_back(j);
        }
    }
}

for (int i=1; i <= n; i++) {
    if (sp[i].size() < 2) {continue;}
    if (used[sp[i][0]] == true or used[sp[i][1]] == true) {continue;}
    v.push_back({sp[i][0], sp[i][1]});
    used[sp[i][0]] = true;
    used[sp[i][1]] = true;
}

cout << v.size() << endl;

for (int i=0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
}

return 0;
}