// Errichto
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
const int nax = 1e5 + 5;
vector<int> w[nax];
int deg[nax];
bool vis[nax];
struct cmp {
bool operator()(int a, int b) {
if(deg[a] != deg[b]) return deg[a] < deg[b];
return a < b;
}
};
typedef set<int,cmp> cc;
void dfs(int a, cc & s) {
s.insert(a);
vis[a] = true;
for(int b : w[a]) if(!vis[b]) dfs(b, s);
}
int getReserve(cc & s, int m) {
assert(!s.empty());
auto it = s.begin();
int reserve = m - deg[*it];
++it;
if(it != s.end()) reserve += m - deg[*it];
return reserve;
}
int getOne(cc & s) {
int a = *s.begin();
s.erase(s.begin());
++deg[a];
s.insert(a);
return a;
}
int main() {
int n, m;
scanf("%d%d", &n, &m);
while(m--) {
int a, b;
scanf("%d%d", &a, &b);
--a; --b;
w[a].push_back(b);
w[b].push_back(a);
++deg[a]; ++deg[b];
}
m = *max_element(deg, deg + n);
long long totalReserve = (long long) m * n - accumulate(deg, deg + n, 0);
vector<cc> all;
REP(i, n) if(!vis[i]) {
cc s;
dfs(i, s);
all.push_back(s);
bool ok = false;
for(int a : s) if(deg[a] < m) ok = true;
if(!ok) ++m;
}
while(totalReserve < 2 * (int) all.size() - 2) {
// while(totalReserve < 2 * n - 2) {
totalReserve += n;
++m;
}
for(cc & s : all) {
bool ok = false;
for(int a : s) if(deg[a] < m) ok = true;
if(!ok) ++m;
}
int countConnected = all.size();
vector<cc> leaves, normals;
for(cc & s : all) {
int reserve = getReserve(s, m);
if(reserve == 1) leaves.push_back(s);
if(reserve > 1) normals.push_back(s);
}
vector<pair<int,int>> ans;
while(int(normals.size() + leaves.size()) >= 2) {
if(leaves.empty()) {
leaves.push_back(normals.back());
normals.pop_back();
}
if(normals.empty()) {
normals.push_back(leaves.back());
leaves.pop_back();
}
cc & a = normals.back();
assert(!leaves.empty());
cc & b = leaves.back();
ans.push_back({getOne(a), getOne(b)});
leaves.pop_back();
if(getReserve(a, m) == 1) {
leaves.push_back(a);
normals.erase(normals.end()-1);
}
}
// printf("%d %d\n", (int) ans.size(), countConnected-1);
assert((int) ans.size() == countConnected - 1);
printf("%d\n", (int) ans.size());
for(pair<int,int> p : ans) printf("%d %d\n", p.first+1, p.second+1);
return 0;
}
Ly8gRXJyaWNodG8KI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBGT1IoaSxhLGIpIGZvcihpbnQgaSA9IChhKTsgaSA8PSAoYik7ICsraSkKI2RlZmluZSBSSShpLG4pIEZPUihpLDEsKG4pKQojZGVmaW5lIFJFUChpLG4pIEZPUihpLDAsKG4pLTEpCgpjb25zdCBpbnQgbmF4ID0gMWU1ICsgNTsKdmVjdG9yPGludD4gd1tuYXhdOwppbnQgZGVnW25heF07CmJvb2wgdmlzW25heF07CgpzdHJ1Y3QgY21wIHsKCWJvb2wgb3BlcmF0b3IoKShpbnQgYSwgaW50IGIpIHsKCQlpZihkZWdbYV0gIT0gZGVnW2JdKSByZXR1cm4gZGVnW2FdIDwgZGVnW2JdOwoJCXJldHVybiBhIDwgYjsKCX0KfTsKdHlwZWRlZiBzZXQ8aW50LGNtcD4gY2M7Cgp2b2lkIGRmcyhpbnQgYSwgY2MgJiBzKSB7CglzLmluc2VydChhKTsKCXZpc1thXSA9IHRydWU7Cglmb3IoaW50IGIgOiB3W2FdKSBpZighdmlzW2JdKSBkZnMoYiwgcyk7Cn0KCmludCBnZXRSZXNlcnZlKGNjICYgcywgaW50IG0pIHsKCWFzc2VydCghcy5lbXB0eSgpKTsKCWF1dG8gaXQgPSBzLmJlZ2luKCk7CglpbnQgcmVzZXJ2ZSA9IG0gLSBkZWdbKml0XTsKCSsraXQ7CglpZihpdCAhPSBzLmVuZCgpKSByZXNlcnZlICs9IG0gLSBkZWdbKml0XTsKCXJldHVybiByZXNlcnZlOwp9CgppbnQgZ2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