Language: C++

//2019.7.14 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 5.6e-8
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e5+10;
namespace MAIN{
    int n,m;
    vector<int> G[N];
    struct P{
        int du,id;
        P() {}
        P(res du,res id):du(du),id(id) {}
        inline bool operator < (const RG P &b) const {
            return du<b.du;
        }
    }a[N];
    inline void addedge(const res &u,const res &v){
        G[u].pb(v),a[u].du++;
        G[v].pb(u),a[v].du++;
    }
    inline bool cmp(const res &x,const res &y){
        return a[x].du>4 4
        1 2
        2 3
        3 4
        4 1a[y].du;
    }
    int du[N],fl[N];
    inline void MAIN(){
        n=read(),m=read();
        for(res i=1;i<=n;i++)a[i]=P(0,i);
        for(res i=1;i<=m;i++)addedge(read(),read());
        if(m&1){puts("-1");return;}
        for(res i=1;i<=n;i++)sort(G[i].begin(),G[i].end(),cmp);
        sort(a+1,a+n+1);
        for(res p=1;p<=n;p++){
            res x=a[p].id,tot=0;
            fl[x]=1;
            for(auto i:G[x]){
                if(fl[i])continue;
                tot++;
            }
            if((du[x]+tot)&1){
                for(auto i:G[x]){
                    if(fl[i])continue;
                    if(!tot)break;
                    if(tot==1)printf("%d %d\n",i,x),du[i]++;
                    else printf("%d %d\n",x,i),du[x]++;
                    tot--;
                }
            }
            else {
                for(auto i:G[x]){
                    if(fl[i])continue;
                    if(!tot)break;
                    printf("%d %d\n",x,i),du[x]++,tot--;
                }
            }
        }
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("zao.in","r",stdin);
//    freopen("std.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Compiler output:
a.cc: In function 'int read()':
a.cc:25:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |     res s=0,ch=gc();
      |         ^
a.cc:25:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |     res s=0,ch=gc();
      |             ^~
a.cc: At global scope:
a.cc:50:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 | inline void swap(res &x,res &y) {
      |                       ^
a.cc:50:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   50 | inline void swap(res &x,res &y) {
      |                              ^
a.cc:61:15: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   61 |         P(res du,res id):du(du),id(id) {}
      |               ^~
a.cc:61:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   61 |         P(res du,res id):du(du),id(id) {}
      |                      ^~
a.cc:62:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   62 |         inline bool operator < (const RG P &b) const {
      |                                             ^
a.cc:66:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   66 |     inline void addedge(const res &u,const res &v){
      |                                    ^
a.cc:66:49: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   66 |     inline void addedge(const res &u,const res &v){
      |                                                 ^
a.cc:70:32: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   70 |     inline bool cmp(const res &x,const res &y){
      |                                ^
a.cc:70:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   70 |     inline bool cmp(const res &x,const res &y){
      |                                             ^
a.cc: In function 'bool MAIN::cmp(const int&, const int&)':
a.cc:71:25: error: expected ';' before numeric constant
   71 |         return a[x].du>4 4
      |                         ^~
      |                         ;
a.cc:71:27: error: expected ';' before numeric constant
   71 |         return a[x].du>4 4
      |                           ^
      |                           ;
   72 |         1 2
      |         ~                  
a.cc: In function 'void MAIN::MAIN()':
a.cc:80:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   80 |         for(res i=1;i<=n;i++)a[i]=P(0,i);
      |                 ^
a.cc:81:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   81 |         for(res i=1;i<=m;i++)addedge(read(),read());
      |                 ^
a.cc:83:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   83 |         for(res i=1;i<=n;i++)sort(G[i].begin(),G[i].end(),cmp);
      |                 ^
a.cc:85:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   85 |         for(res p=1;p<=n;p++){
      |                 ^
a.cc:86:17: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   86 |             res x=a[p].id,tot=0;
      |                 ^
a.cc:86:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   86 |             res x=a[p].id,tot=0;
      |                           ^~~