#include <bits/stdc++.h>
#define inf 4294967295
#define MAXN 500100
#define LL long long
#define pi acos(-1)
#define MOD 332748118
using namespace std;
struct pp{
int x,y;
} ans[MAXN];
int ot[MAXN],ne[MAXN],g[MAXN],e,d[MAXN],f[MAXN];
void add(int x,int y){
ot[++e]=y,ne[e]=g[x],g[x]=e;
ot[++e]=x,ne[e]=g[y],g[y]=e;
}
int n,m;
set<int> a,b;
int main()
{
scanf("%d%d",&n,&m);
for (int i = 1; i <= m; ++i){
int x,y;
scanf("%d%d",&x,&y);
add(x,y);
d[x]++,d[y]++;
}
for (int i = 1; i <= n; ++i) f[i] = 0;
for (int i = 1; i <= n; ++i) if (d[i]%2) a.insert(i);else b.insert(i);
int tot=0;
set<int>::iterator it;
int pp = 1;
while (tot<m){
it=b.begin();
if (it==b.end()){
pp = 0;
break;
}
int x = *it;
f[x] = 1;
b.erase(x);
//cout << x << " " << d[x] << endl;
for (int p = g[x]; p; p = ne[p]){
int y = ot[p];
if (!f[y]){
ans[++tot].x = x, ans[tot].y = y;
if (d[y]%2){
a.erase(y);d[y]--;
b.insert(y);
} else {
b.erase(y);d[y]--;
a.insert(y);
}
}
}
}
if (!pp) puts("-1");
else {
for (int i = 1; i <= m; ++i) printf("%d %d\n",ans[i].x,ans[i].y);
}
return 0;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:26:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:29:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&x,&y);
^