Language: C++

#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 300011;
const ll INF = 5e16;

namespace IO {

	inline char gc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return (p1 == p2) && (p2 = (p1 = buf) +
			fread (buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
	}

	#define dd ch = getchar()
	inline ll read() {
		R ll x = 0; R int f = 0; R char dd;
		for (; !isdigit (ch); dd) f ^= (ch == '-');
		for (; isdigit (ch); dd)  x = x * 10 + (ch ^ 48);
		return f? -x: x;
	}
	#undef dd

	inline void write( ll x ) {
		if (x < 0) putchar ('-'), x = -x;
		if (x > 9) write (x / 10); putchar (x % 10 | 48);
	}

	inline void wrn ( ll x ) { write (x); putchar (' '); }

	inline void wln ( ll x ) { write (x); putchar ('\n'); }

	inline void wlnn ( ll x, ll y ) { wrn (x), wln (y); }

}

using IO::wln;
using IO::wlnn;
using IO::read;

namespace Cesare {
	
	ll n, m, cc = 0, Deg[N], W[N], V[N];
	
	vector <ll> Ve[N], E[N];
	
	int main() {
		n = read(), m = read();
		for (R int i = 1, u, v; i <= m; ++i) 
			++Deg[u = read()], Ve[u].push_back(v = read());
		For ( i, 1, n ) if (Deg[i] & 1) ++cc;
		if (cc & 1) return puts ("-1"), 0;
		For ( u, 1, n ) {
			if (Deg[u] & 1) {
				ll Z = 0, v;
				For ( i, 1, Ve[u].size() ) 
					v = Ve[u][i - 1], Z += (Deg[v] & 1);
				if (Z & 1) {
					For ( i, 1, Ve[u].size() ) {
						v = Ve[u][i - 1];
						if (Deg[u] && (Deg[v] & 1)) {
							E[v].push_back(u);
							--Deg[u], ++Deg[v];
						} else E[u].push_back(v);
					}
				} else {
					For ( i, 1, Ve[u].size() ) {
						v = Ve[u][i - 1];
						if (Deg[u] && (Deg[v] & 1) && Z > 1) {
							--Z;
							E[v].push_back(u);
							--Deg[u], ++Deg[v]; 
						} else E[u].push_back(v);
					}
				}
			} else {
				ll Z = 0, v;
				For ( i, 1, Ve[u].size() ) 
					v = Ve[u][i - 1], Z += (Deg[v] & 1);
				if (!(Z & 1) {
					For ( i, 1, Ve[u].size() ) {
						v = Ve[u][i - 1];
						if (Deg[u] && (Deg[v] & 1)) {
							E[v].push_back(u);
							--Deg[u], ++Deg[v];
						} else E[u].push_back(v);
					}
				} else {
					For ( i, 1, Ve[u].size() ) {
						v = Ve[u][i - 1];
						if (Deg[u] && (Deg[v] & 1) && Z > 1) {
							--Z;
							E[v].push_back(u);
							--Deg[u], ++Deg[v]; 
						} else E[u].push_back(v);
					}
				}
			}
		}
		For ( u, 1, n ) For ( i, 1, E[u].size() ) 
			wlnn (u, E[u][i - 1]);
		return 0;
	} 
}

int main()
{
	return Cesare::main();
}

/*

*/






Compiler output:
a.cc: In function 'll IO::read()':
a.cc:27:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |                 R ll x = 0; R int f = 0; R char dd;
      |                      ^
a.cc:27:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |                 R ll x = 0; R int f = 0; R char dd;
      |                                   ^
a.cc:25:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |         #define dd ch = getchar()
      |                    ^~
a.cc:27:49: note: in expansion of macro 'dd'
   27 |                 R ll x = 0; R int f = 0; R char dd;
      |                                                 ^~
a.cc: In function 'int Cesare::main()':
a.cc:59:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |                 for (R int i = 1, u, v; i <= m; ++i)
      |                            ^
a.cc:59:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |                 for (R int i = 1, u, v; i <= m; ++i)
      |                                   ^
a.cc:59:38: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   59 |                 for (R int i = 1, u, v; i <= m; ++i)
      |                                      ^
a.cc:61:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   61 |                 For ( i, 1, n ) if (Deg[i] & 1) ++cc;
      |                       ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:61:17: note: in expansion of macro 'For'
   61 |                 For ( i, 1, n ) if (Deg[i] & 1) ++cc;
      |                 ^~~
a.cc:63:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   63 |                 For ( u, 1, n ) {
      |                       ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:63:17: note: in expansion of macro 'For'
   63 |                 For ( u, 1, n ) {
      |                 ^~~
a.cc:66:39: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   66 |                                 For ( i, 1, Ve[u].size() )
      |                                       ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:66:33: note: in expansion of macro 'For'
   66 |                                 For ( i, 1, Ve[u].size() )
      |                                 ^~~
a.cc:69:47: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   69 |                                         For ( i, 1, Ve[u].size() ) {
      |                                               ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:69:41: note: in expansion of macro 'For'
   69 |                                         For ( i, 1, Ve[u].size() ) {
      |                                         ^~~
a.cc:77:47: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   77 |                                         For ( i, 1, Ve[u].size() ) {
      |                                               ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:77:41: note: in expansion of macro 'For'
   77 |                                         For ( i, 1, Ve[u].size() ) {
      |                                         ^~~
a.cc:88:39: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   88 |                                 For ( i, 1, Ve[u].size() )
      |                                       ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:88:33: note: in expansion of macro 'For'
   88 |                                 For ( i, 1, Ve[u].size() )
      |                                 ^~~
a.cc:90:45: error: expected ')' before '{' token
   90 |                                 if (!(Z & 1) {
      |                                    ~        ^~
      |                                             )
a.cc:108:25: error: expected primary-expression before '}' token
  108 |                         }
      |                         ^
a.cc:110:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  110 |                 For ( u, 1, n ) For ( i, 1, E[u].size() )
      |                       ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:110:17: note: in expansion of macro 'For'
  110 |                 For ( u, 1, n ) For ( i, 1, E[u].size() )
      |                 ^~~
a.cc:110:39: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  110 |                 For ( u, 1, n ) For ( i, 1, E[u].size() )
      |                                       ^
a.cc:9:32: note: in definition of macro 'For'
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                ^
a.cc:9:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    9 | #define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
      |                                         ^~
a.cc:110:33: note: in expansion of macro 'For'
  110 |                 For ( u, 1, n ) For ( i, 1, E[u].size() )
      |                                 ^~~