#include<bits/stdc++.h>
using namespace std;
vector<int> graph[100000];
long long cv[1000000];
bool uc[1000000];
vector<pair<int, int>> ans;
int main () {
    int n, m;
    cin >> m >> n;
    for(int i = 0; i < n; i++){
        int a1, b1;
        cin >> a1 >> b1;
        if(cv[a1] == 0){
            cv[a1] = i + 1;
        }else{
            if(!uc[cv[a1]] && !uc[i + 1]){
                ans.push_back({cv[a1], i + 1});
                uc[cv[a1]] = true;
                uc[i + 1] = true;
            }
        }
        if(cv[b1] == 0){
            cv[b1] = i + 1;
        }else{
            if(!uc[cv[b1]] && !uc[i + 1]){
                ans.push_back({cv[b1], i + 1});
                uc[cv[b1]] = true;
                uc[i + 1] = true;
            }
        }
    }
    /*int t = 1;
    for(int i = 1; i <= n; i++){
        if(visited[i] != 0){
            visited[i] = t;
            queue<int> font;
            font.push(i);
            while(!font.empty()){
                long long curr = font.front();
                font.pop();
                for(int i = 0 ; i < graph[curr].size(); i++){
                    if(visited[graph[curr][i]] == 0){
                        visited[graph[curr][i]] = t;
                        font.push(graph[curr][i]);
                    }
                }
            }
        }
        t++;
    }
    for(int i = 0; i < n; i++){
        m[visited[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(m[i] > 0){
            for(int i = 0)
        }
    }*/

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

    return 0;
}
