Language: C++

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
#define fi first
#define se second
#define REP(i, a, n) for (int (i)=(a);(i)<(n);(i)++)
#define PER(i, a, n) for (int (i)=(n)-1;(i)>=(a);(i)--)

typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VPI;

//#ifndef ONLINE_JUDGE
#define dbb(x)        { cerr << #x << " = " << x << "\t";      }
#define db(x)        { dbb(x); cerr << endl; }
#define db2(x, y)    { dbb(x); dbb(y); cerr << endl; }
#define db3(x, y, z)    { dbb(x); dbb(y); dbb(z); cerr << endl; }
//#else
//#define dbb(x)		;
//#define db(x)		;
//#define db2(x,y)	;
//#define db3(x,y,z)	;
//#endif



const ll MOD = 1000000007ll;

ll powmod(ll a, ll b) {
        ll res = 1;
        a %= MOD;
        assert(b >= 0);
        for (; b; b >>= 1) {
                if (b & 1) res = res * a % MOD;
                a = a * a % MOD;
        }
        return res;
}

template<typename t1, typename t2>
inline bool upmax(t1 &a, t2 b) {
        if (a < (t1) b) {
                a = (t1) b;
                return true;
        } else return false;
}

template<typename t1, typename t2>
inline bool upmin(t1 &a, t2 b) {
        if (a > (t1) b) {
                a = (t1) b;
                return true;
        } else return false;
}

template<typename T>
inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<typename T>
inline T lcm(T a, T b) { return a * (b / gcd(a, b)); }

template<typename T>
inline T sqr(T a) { return a * a; }

int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int dkx[] = {-1, -1, 1, 1, -2, -2, 2, 2};
int dky[] = {-2, 2, -2, 2, -1, 1, -1, 1};

const int INF = 1000000404;
const ll LINF = 1e18 * (1ll);
const ld PI = 3.14159265358979323846;
const ld EPS = 1e-9;

const int SQ = 318;
int timer = 0;

#define N 100100

VI g[N];
int deg[N];
bool deleted[N];

void solve() {


        int n;
        cin >> n;
        int m;
        cin >> m;
        REP(i, 0, m) {
                int a, b;
                cin >> a >> b;
                deg[a] ^= 1;
                deg[b] ^= 1;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        set<int> ev;
        REP(i, 1, n + 1) {
                if (deg[i] == 0) {
                        ev.insert(i);
                }
        }

        VPI ans;
        int cnt = 0;
        while (!ev.empty()) {
                int v = *ev.begin();
                ev.erase(ev.begin());
                deleted[v] = true;
                cnt++;
                int odd = 0;
                int even = 0;
                for (auto x:g[v]) {
                        if (!deleted[x]) {
                                if (deg[x]) odd++;
                                else even++;
                        }
                }

                for (auto x:g[v]) {
                        if (!deleted[x]) {
                                if (odd < even)
                                        ans.push_back(MP(v, x));
                                else ans.push_back(MP(x, v));
                                deg[x] ^= 1;
                                if (deg[x]) {
                                        ev.erase(x);
                                } else ev.insert(x);
                        }
                }
        }

        if (SZ(ans) != m || cnt != n) {
                cout << -1;
        } else {
                for (auto x:ans) cout << x.first << ' ' << x.second << endl;
        }

}

int main() {

#ifndef ONLINE_JUDGE
#else
        //freopen("mantan.in", "r", stdin);
        //freopen("mantan.out", "w", stdout);
#endif

        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);

        int t = 1;
        //cin >> t;
        for (int i = 1; i <= t; i++) {
                solve();
        }


        return 0;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:5:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~