random_shuffle(a+1,a+1+n) 入门。。。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
#include<map>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define MAXN (100000+10)
#define MAXM (100000+10)
long long mul(long long a,long long b){return (a*b)%F;}
long long add(long long a,long long b){return (a+b)%F;}
long long sub(long long a,long long b){return (a-b+(a-b)/F*F+F)%F;}
typedef long long ll;
int n,m;
map<pair<int,int>,bool> h;
int degree[MAXN]={0},ans[MAXN];
bool check()
{
For(i,m) if (h[make_pair(ans[i],ans[i+1])]) return 1;
For(i,n) degree[i]=0;
For(i,m+1) degree[ans[i]]+=1+(1<i&&i<m+1);
For(i,m+1) if (degree[ans[i]]>2) return 1;
if (m+1==3&&ans[1]==ans[3]) return 1;
return 0;
}
int main()
{
// freopen("Graph Reconstruction.in","r",stdin);
scanf("%d%d",&n,&m);
For(i,m) {int u,v;scanf("%d%d",&u,&v); h[make_pair(u,v)]=h[make_pair(v,u)]=1; }
For(i,n) h[make_pair(i,i)]=1;
//cout<<h[make_pair(8,7)]<<endl;
For(i,n) ans[i]=i;
int T=3000000/m;
while (T--)
{
random_shuffle(ans+1,ans+1+n);ans[0]=ans[n];//0..n 每个数出现一次,1个出现2次 的 rand_seq
int cnt=0;
Rep(i,n) if (!h[make_pair(ans[i],ans[i+1])]) cnt++;
if (cnt<m) continue;
{
for(int i=0;m;i++) if (!h[make_pair(ans[i],ans[i+1])]) printf("%d %d\n",ans[i],ans[i+1]),m--;
return 0;
}
}
//puts("-1");
puts("-1");
return 0;
}