#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

    pair<int,int>uch[5001];
    vector<int>ans[1001],koi;
    int br[1001];
    bool bqh[11];


int main(){

    long long n,m;
    cin>>n>>m;


    if(m<11 && n<11){
        int a,b;
        string tr;
        for(int i=0;i<m;i++){
            cin>>a>>b;
            tr+=(i+'0');
            uch[i]=make_pair(a,b);
        }

        int ans=0,br;
        vector<int>otg,cr,now;
        while(next_permutation(tr.begin(),tr.end())){
            br=0;
            now=cr;
            for(int i=0;i<tr.size()-1;i++){
                if(uch[tr[i]-'0'].first==uch[tr[i+1]-'0'].first || uch[tr[i]-'0'].first==uch[tr[i+1]-'0'].second ||
                   uch[tr[i]-'0'].second==uch[tr[i+1]-'0'].first || uch[tr[i]-'0'].second==uch[tr[i+1]-'0'].second){
                    br++;
                    now.push_back(100*(tr[i]-'0')+tr[i+1]-'0');
                    i++;
                }
            }
            if(br>ans){
                ans=br;
                otg=now;
            }
        }

    cout<<ans<<endl;
    for(int i=0;i<otg.size();i++){
        cout<<otg[i]/100+1<<" "<<otg[i]%100+1<<endl;
    }

    }else{

        int a,b;
        for(int i=0;i<m;i++){
            cin>>a>>b;
            br[a]++;
            br[b]++;
            if(br[a]>1)koi.push_back(a);
            if(br[b]>1)koi.push_back(b);
            uch[i]=make_pair(a,b);
        }
        int otg=0;
        for(int i=0;i<m;i++){
            bool yes=false;
            for(int j=0;j<koi.size() && yes==false;j++){
                if(uch[i].first==koi[j]){
                    ans[koi[j]].push_back(i);
                    if(ans[koi[j]].size()==1)otg++;
                    yes=true;
                }else{
                    if(uch[i].second==koi[j]){
                        ans[koi[j]].push_back(i);
                        if(ans[koi[j]].size()==1)otg++;
                        yes=true;
                    }
                }
            }
        }
        cout<<otg<<endl;
        for(int i=1;i<=n;i++){
            if(ans[i].size()>0){
                cout<<ans[i][0]+1<<" "<<ans[i][1]+1<<endl;
            }
        }

    }


    return 0;
}
