func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, M;   vector<set<int> > A;   vector<set<pair<int, int> > > B;   vector<int> d, f, F, G;   vector<bool> v;   inline void upd(int& a, int b) {     if (d[a] > d[b]) a = b;   }   void ff(int x, int y) {     f[x] = x, v[x] = 1;     for (set<int>::iterator i = A[x].begin(); i != A[x].end(); i++)       if (v[*i]) {         if (*i != y) upd(f[x], *i);       } else         d[*i] = d[x] + 1, ff(*i, x), upd(f[x], f[*i]);   }   void ff(int x) {     f[x] = f[f[x]], v[x] = 0;     for (set<int>::iterator i = A[x].begin(); i != A[x].end(); i++)       if (v[*i]) ff(*i);   }   bool gg(int x, int y, int fa) {     if (x == y) return 1;     for (set<pair<int, int> >::iterator i = B[x].begin(); i != B[x].end(); i++)       if (i->first != fa)         if (gg(i->first, y, x)) {           v[i->second] = v[i->second ^ 1] = 1;           return 1;         }     return 0;   }   int main() {     scanf( %d%d , &n, &m);     A.resize(n);     for (int i = 0, x, y; i < m; i++)       scanf( %d%d , &x, &y), --x, --y, A[x].insert(y), A[y].insert(x);     if (n == 2) {       puts( -1 );       return 0;     }     d.resize(n, 0), f.resize(n), v.resize(n, 0);     ff(0, -1), ff(0);     F.resize(n);     for (int i = 0; i < n; i++)       if (f[i] == i) F[i] = (int)G.size(), G.push_back(i);     for (int i = 0; i < n; i++) F[i] = F[f[i]];     B.resize((int)G.size());     for (int i = 0; i < n; i++)       for (set<int>::iterator j = A[i].begin(); j != A[i].end(); j++)         if (F[i] != F[*j]) {           set<pair<int, int> >::iterator p =               B[F[i]].lower_bound(make_pair(F[*j], -1));           if (p != B[F[i]].end() && p->first == F[*j]) continue;           B[F[i]].insert(make_pair(F[*j], M++)),               B[F[*j]].insert(make_pair(F[i], M++));         }     if ((int)G.size() == 1) {       puts( 0 );       return 0;     }     if ((int)G.size() == 2) {       puts( 1 );       for (int i = 0; i < n; i++)         for (int j = i + 1; j < n; j++)           if (F[i] != F[j] && A[i].find(j) == A[i].end()) {             printf( %d %d n , i + 1, j + 1);             return 0;           }     }     vector<int> L;     for (int i = 0; i < (int)G.size(); i++)       if ((int)B[i].size() == 1) L.push_back(i);     printf( %d n , ((int)L.size() + 1) / 2);     while (1) {       random_shuffle(L.begin(), L.end());       bool F = 0, FF = 1;       if ((int)L.size() & 1) F = 1, L.push_back(L[0]);       v.clear(), v.resize(M, 0);       for (int i = 0; i < (int)L.size(); i += 2) gg(L[i], L[i + 1], -1);       for (int i = 0; i < M; i++)         if (!v[i]) {           FF = 0;           break;         }       if (FF) {         for (int i = 0; i < (int)L.size(); i += 2)           printf( %d %d n , G[L[i]] + 1, G[L[i + 1]] + 1);         return 0;       }       if (F) L.erase(L.end() - 1);     }     return 0;   }   