Language: C++

#include <bits/stdc++.h>
using namespace std;

#define fst first
#define snd second
#define mp make_pair
#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)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

template <typename T1, typename T2>
inline bool umin(T1& x, const T2& y){return y<x ? x=y,true : false;}

template <typename T1, typename T2>
inline bool umax(T1& x, const T2& y){return x<y ? x=y,true : false;}

typedef long long ll;
typedef long double ld;

const int N    = (int)1e6+7;
const int mod  = (int)1e9+7;
const int INF  = (int)1e9+17;
const ll LLINF = (ll)1e18+17;


int n, m;
int deg[N];
int lazy[N];
bool used[N];
vector<int> g[N];
vector<int> r[N];
set<pair<int,int>> ans;

namespace dsu {
    int p[N];
    int sz[N];

    inline void init(int n) {
        fill(p, p+n, -1);
        fill(sz, sz+n, 1);
    }

    int find(int v) {
        if (p[v] == -1) return v;
        return p[v] = find(p[v]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        p[y] = x;
        return true;
    }
}

namespace lca {
    int up[N][21];
    int in[N], out[N];
    void dfs(int v, int p) {
        static int timer = 0;
        in[v] = ++timer;
        up[v][0] = p;
        rep(i, 1, 20) up[v][i] = up[up[v][i-1]][i-1];
        for(int to : r[v]) {
            if (to == p) continue;
            dfs(to, v);
        }
        out[v] = ++timer;
    }
    bool upper(int x, int y) {
        return in[x] <= in[y] && out[y] <= out[x];
    }
    int get(int x, int y) {
        if (upper(x, y)) return x;
        if (upper(y, x)) return y;
        per(i, 0, 20) {
            if (!upper(up[x][i], y)) x = up[x][i];
        }
        return up[x][0];
    }
}


inline void set_direction(int x, int y) {
    if (ans.count({y, x})) {
        ans.erase({y, x});
        --deg[y];
    }
    ++deg[x];
    ans.insert({x, y});
}

inline void reverse_direction(int x, int y) {
    if (ans.count({x, y}))
        set_direction(y, x);
    set_direction(x, y);
}

void dfs(int v) {
    used[v] = true;
    for(int to : g[v]) {
        if (!used[to]) dfs(to);
        set_direction(v, to);
    }
}

int restore(int v, int p) {
    int blc = lazy[v];
    for(int to : r[v]) {
        if (to == p) continue;
        blc += restore(to, v);
    }
    if (blc % 2 == 1) {
        reverse_direction(v, p);
    }
    return blc;
}

void reverse_on_path(int x, int y) {
    int v = lca::get(x, y);
    ++lazy[x], ++lazy[y];
    lazy[v] -= 2;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
#endif

    cin >> n >> m;
    dsu::init(n);
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        g[x].push_back(y);
        g[y].push_back(x);
        ++deg[x];
        if (dsu::unite(x, y)) {
            set_direction({x, y});
            r[x].push_back(y);
            r[y].push_back(x);
        }
    }
    vector<int> odd;
    rep(v, 0, n) if (deg[v] % 2 == 1) odd.push_back(v);
    if (odd.size() % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }
    lca::dfs(0, 0);
    while (!odd.empty()) {
        int x = odd.back();
        odd.pop_back();
        int y = odd.back();
        odd.pop_back();
        reverse_on_path(x, y);
    }
    restore(0, 0);
    rep(i, 0, n) assert(deg[i] % 2 == 0);
    for(const auto& e : ans) {
        cout << e.fst + 1 << ' ' << e.snd + 1 << '\n';
    }

    return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:145:26: error: cannot convert '<brace-enclosed initializer list>' to 'int'
  145 |             set_direction({x, y});
      |             ~~~~~~~~~~~~~^~~~~~~~
      |                          |
      |                          <brace-enclosed initializer list>
a.cc:86:31: note:   initializing argument 1 of 'void set_direction(int, int)'
   86 | inline void set_direction(int x, int y) {
      |                           ~~~~^