Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
using namespace std;

inline int read(){
	long long s=0,w=1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		s = s*10+ch-'0';
		ch = getchar();
	}
	return w*s;
}

int n,m;
int tot = 0;
int head[100005],ver[100005],next[100005];
bool val[100005];

void add(int x,int y){
	ver[++tot] = y,next[tot] = head[x],head[x] = tot;
	val[tot] = 1;//1代表被点亮，即x->y 
	ver[++tot] = x,next[tot] = head[y],head[y] = tot;
	val[tot] = 0;
}//奇数位的边开始都是亮的，都是x->y 

int num[100005];
int to_go[100005];

//int way[100005];
int vis[100005];

void dfs(int x,int dep,bool &got,int from){
	//cout << "vis " << x << endl;
	vis[x] = 1;
	if(!got){
		if(to_go[x] == 1){//gotcha!
			//cout << "dep " << dep << " x " << x << endl;
			to_go[x] = 0;
			//way[dep] = x;
			if(from){
				if(from%2){
					val[from] = 1^val[from];
					val[from+1] = 1^val[from+1];
				}else{
					val[from] = 1^val[from];
					val[from-1] = 1^val[from-1];
				}
			}
			
			got = 1;
			
			vis[x] = 0;
			return;
		}
		for(int i = head[x];i && !vis[ver[i]];i = next[x]){//边不管亮不亮都可以跑 
			dfs(ver[i],dep+1,got,i);
			if(got = 1){
				//way[dep] = x;
				//cout << "dep " << dep << " x " << x << endl;
				if(from){
					//cout << "low from" << endl; 
					if(from%2){
						val[from] = 1^val[from];
						val[from+1] = 1^val[from+1];
					}else{
						val[from] = 1^val[from];
						val[from-1] = 1^val[from-1];
					}
				}
				break;
			}
		}
	}
	vis[x] = 0;
	return;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	int x,y;
	for(int i = 1;i <= m;++i){
		x = read();
		y = read();
		add(x,y);
		++num[x];
	}
	
	int cnt = 0;
	for(int i = 1;i <= n;++i){
		if(num[x]%2 == 1){
			++cnt;
			to_go[i] = 1;
		}
	}

	if(cnt%2 == 1){
		cout << -1;
		return 0;
	}else{
		for(int i = 1;i <= n;++i){
			bool gotcha = 0;
			//memset(way,0,sizeof(way));
			memset(vis,0,sizeof(vis));
			if(to_go[i]){
				to_go[i] = 0;
				dfs(i,1,gotcha,0);
			}
		}
	}
	
	for(int i = 1;i <= n;++i){
		for(int j = head[i];j;j = next[j]){
			if(val[j]){
				cout << i << " " << ver[j] << endl;
			}
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'void add(int, int)':
a.cc:28:24: error: reference to 'next' is ambiguous
   28 |         ver[++tot] = y,next[tot] = head[x],head[x] = tot;
      |                        ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:30: note:                 'int next [100005]'
   24 | int head[100005],ver[100005],next[100005];
      |                              ^~~~
a.cc:30:24: error: reference to 'next' is ambiguous
   30 |         ver[++tot] = x,next[tot] = head[y],head[y] = tot;
      |                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:30: note:                 'int next [100005]'
   24 | int head[100005],ver[100005],next[100005];
      |                              ^~~~
a.cc: In function 'void dfs(int, int, bool&, int)':
a.cc:63:59: error: reference to 'next' is ambiguous
   63 |                 for(int i = head[x];i && !vis[ver[i]];i = next[x]){//边不管亮不亮都可以跑
      |                                                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:30: note:                 'int next [100005]'
   24 | int head[100005],ver[100005],next[100005];
      |                              ^~~~
a.cc: In function 'int main()':
a.cc:121:43: error: reference to 'next' is ambiguous
  121 |                 for(int j = head[i];j;j = next[j]){
      |                                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:24:30: note:                 'int next [100005]'
   24 | int head[100005],ver[100005],next[100005];
      |                              ^~~~