#include<bits/stdc++.h>
using namespace std;
long long cv[1000007];
bool uc[1000006];
vector<pair<long long, long long>> ans;
int main () {
    long long n, m;
    cin >> m >> n;
    for(long long i = 0; i < n; i++){
        long long 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;
                cv[a1] = 0;
            }
        }
        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;
                cv[b1] = 0;
            }
        }
    }


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

    return 0;
}
