stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <vector>

#include <queue>

using namespace std;

typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)

#define repe(i,s,n)for(ll i=s;i<=n;i++)



static const ll MOD = 1e9 + 7;

static const ll INF = (ll)1 << 62;



static const ll MAX_N = 100001;

static const ll MAX_M = 200001;



ll V;

ll d[MAX_N] = {};

struct edge { ll to, cost; };

typedef pair<ll, ll> P;

vector<edge> G[MAX_N];

priority_queue <P, vector<P>, greater<P>> que;

bool mst[MAX_N];



ll cost = 0;



bool complete() {

	ll cnt = 0;

	rep(i, 0, V) {

		if (mst[i])cnt++;

	}

	return (cnt == V);

}



void prim(ll s) {

	fill(d, d + V, INF);

	d[s] = 0;

	que.push(P(0, s));



	while (!que.empty()) {

		P p = que.top(); que.pop();

		ll v = p.second;

		if (mst[v])continue;



		cost += p.first;

		mst[v] = true;



		rep(i, 0, G[v].size()) {

			edge e = G[v][i];

			if (!mst[e.to]) {

				que.push(P(e.cost, e.to));

			}

		}



		if (complete())break;

	}

}



int main() {

	//freopen("C://testcase//in7.txt", "r", stdin);



	ll E; cin >> V >> E;

	rep(i, 0, E) {

		ll s, t, d; cin >> s >> t >> d;

		G[s].push_back(edge{ t,d });

		G[t].push_back(edge{ s,d });

	}



	prim(0);



	cout << cost << endl;



	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.5261006543959947x):
#include <iostream>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <queue>

using namespace std;

#define rep(i,s,n)for(int i = s;i<n;i++)

#define repe(i,s,n)for(int i = s;i<=n;i++)

typedef long long ll;

static const ll MOD = 1e9 + 7;

static const ll INF = (ll)1 << 62;



//////////////////////////////////////////////////////

//Union Find /////////////////////////////////////////

//////////////////////////////////////////////////////

static const ll MAX_M = 100001;

static const ll MAX_N = 100001;

int par[MAX_N];

int rak[MAX_N];



void init(int n) {

	rep(i, 0, n) {

		par[i] = i;

		rak[i] = 0;

	}

}



int find(int x) {

	if (par[x] == x)return x;

	else return par[x] = find(par[x]);

}



void unite(int x, int y) {

	x = find(x);

	y = find(y);

	if (x == y)return;



	if (rak[x] < rak[y]) par[x] = y;

	else {

		par[x] = y;

		if (rak[x] == rak[y]) rak[x]++;

	}

}



bool same(int x, int y) {

	return find(x) == find(y);

}



struct edge { int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {

	return e1.cost < e2.cost;

}



int V, E;

edge es[MAX_M];



int krascal() {

	sort(es, es + E, comp);

	init(V);

	int res = 0;



	rep(i, 0, E) {

		edge e = es[i];

		if (!same(e.u, e.v)) {

			unite(e.u, e.v);

			res += e.cost;

		}

	}

	return res;

}



int main() {

	ll n, m; cin >> n >> m;

	V = n, E = m;

	rep(i, 0, m) {

		ll s, t, w; cin >> s >> t >> w;

		edge *e = new edge();

		e->u = s;

		e->v = t;

		e->cost = w;

		es[i] = *e;

	}



	cout << krascal() << endl;



	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;



int main() {

	int x, y;

	cin >> x >> y;

	if (x < y)

	{

		cout << 0;

		return 0;

	}

	cout << 10;

}

// Faster C++ solution for the same problem (measured speedup: 5.264024879038395x):
#include<stdio.h>

int main()

{

	int x,a;

	while(~scanf("%d%d",&x,&a))

	{

		if(x<a)

		printf("0\n");

		else

		printf("10\n");

	}

	return 0;

}//
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>

using namespace std;

int main()

{

	int x, a;

	cin >> x >> a;

	if (x < a)

		cout << 0 << endl;

	else cout << 10 << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.313973707509803x):
#include<stdio.h>

int main()

{

	int x,a;

	while(~scanf("%d%d",&x,&a))

	{

		if(x<a)

		printf("0\n");

		else

		printf("10\n");

	}

	return 0;

}//
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

    int x,n;



    cin>>x>>n;



    if(x<n){

        cout<<0;

    }else{

        cout<<10;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.271763049479647x):
#include<stdio.h>

int main(){

int X,A;

scanf("%d",&X);



scanf("%d",&A);

if(X<A){

        printf("0");



}

else printf("10");

















}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

    int x,n;



    cin>>x>>n;



    if(x<n){

        cout<<0;

    }else{

        cout<<10;

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.270484803826981x):
#include<stdio.h>

int main()

{

	int x,a;

	scanf("%d%d",&x,&a);

	if(x<a)   {   printf("0");  }

	else     {   printf("10");   }

	return 0;

}
// Slower C++ solution:
#include <iostream>

using namespace std;



int main()

{

  int x,a;

  cin>>x>>a;



  if(x>a || x==a)

    cout<<10;

  else

    cout<<0;

}




// Faster C++ solution for the same problem (measured speedup: 5.270479037199256x):
#include<stdio.h>

int main()

{

	int x,a;

	scanf("%d%d",&x,&a);

	if(x<a)   {   printf("0");  }

	else     {   printf("10");   }

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<set>

#include<string>

typedef long long int lli;

using namespace std;

int main(){

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    vector<string> v;

    vector<string> v1;

    

   int a;

   int x;

   cin>>x>>a;

  

   if(x<a){

       printf("0\n");

   }else{

       printf("10\n");

       

   }

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.362272002671824x):
#include<stdio.h>

int main()

{

	int x,a;

	scanf("%d%d",&x,&a);

	if(x<a)   {   printf("0");  }

	else     {   printf("10");   }

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>



using namespace std;



typedef vector<int> vi;

typedef vector<vi> vvi;



const int INFTY=1<<29;



int main()

{

	for(int h,w;cin>>h>>w,h|w;){

		int n=h*w;

		vvi dist(n,vi(n,INFTY));

		vi hearts;

		for(int i=0;i<h;i++){

			for(int j=0;j<w;j++){

				int x; cin>>x;

				if(x==1)

					hearts.push_back(i*w+j);

				

				dist[i*w+j][i*w+j]=0;

				int di[]={-1,1,0,0},dj[]={0,0,-1,1};

				for(int k=0;k<4;k++){

					int ii=i+di[k],jj=j+dj[k];

					if(0<=ii && ii<h && 0<=jj && jj<w)

						dist[i*w+j][ii*w+jj]=dist[ii*w+jj][i*w+j]=1;

				}

			}

		}

		

		for(int k=0;k<n;k++)

			for(int i=0;i<n;i++)

				for(int j=0;j<n;j++)

					dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);

		

		int hsize=hearts.size();

		vvi dp(1<<hsize,vi(n,INFTY));

		for(int i=0;i<hsize;i++)

			for(int j=0;j<n;j++)

				dp[1<<i][j]=dist[hearts[i]][j];

		

		for(int i=0;i<(1<<hsize);i++){

			for(int j=i;j;j=(j-1)&i)

				for(int k=0;k<n;k++)

					dp[i][k]=min(dp[i][k],dp[j][k]+dp[i^j][k]);

			for(int j=0;j<n;j++)

				for(int k=0;k<n;k++)

					dp[i][j]=min(dp[i][j],dp[i][k]+dist[k][j]);

		}

		

		int res=INFTY;

		for(int i=0;i<n;i++)

			res=min(res,dp[(1<<hsize)-1][i]);

		cout<<n-(res+1)<<endl;

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.7208881135527605x):
#include <cstdio>

#include <algorithm>

#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;int dist[144][144],hearts[6],dp[1<<6][144];int di[]={-1,1,0,0},dj[]={0,0,-1,1};int main(){for(int h,w;scanf("%d%d",&h,&w),h|w;){int n=h*w;rep(i,n) rep(j,n) dist[i][j]=1<<29;int hsize=0;rep(i,h) rep(j,w){int x; scanf("%d",&x);if(x==1)hearts[hsize++]=i*w+j;int p=i*w+j;dist[p][p]=0;rep(k,4){int ii=i+di[k],jj=j+dj[k],pp=ii*w+jj;if(0<=ii && ii<h && 0<=jj && jj<w)dist[p][pp]=dist[pp][p]=1;}}rep(k,n) rep(i,n) rep(j,n)dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);rep(i,1<<hsize) rep(j,n)dp[i][j]=1<<29;rep(i,hsize) rep(j,n)dp[1<<i][j]=dist[hearts[i]][j];rep(i,1<<hsize){for(int j=i;j;j=(j-1)&i) rep(k,n)dp[i][k]=min(dp[i][k],dp[j][k]+dp[i^j][k]);rep(j,n) rep(k,n)dp[i][j]=min(dp[i][j],dp[i][k]+dist[k][j]);}int* dpb=dp[(1<<hsize)-1];printf("%d\n",n-(*min_element(dpb,dpb+n)+1));}return 0;}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

 

int main() {

  int m;

  cin >> m;

  cout << 48 - m << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.267170450341728x):
#include <cstdio>

int m;

int main() {

  scanf("%d",&m);

  printf("%d\n",48-m);

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<vector>

#include<cmath>

#include<queue>

#include<stack>

#include<set>

#include<algorithm>

#include<utility>

#include<map>

using namespace std;

typedef long long ll;

const int mod = 1000000007;

const int INF = 1001001001;



ll pow_mod(ll p, ll n, ll m) {

	if (n == 0) return 1;

	else if (n == 1) return p % m;

	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;

	else {

		ll tmp = pow_mod(p, n / 2, m);

		return (tmp * tmp) % m;

	}

}



ll gcd(ll x, ll y) {

	if (y == 0) {

		return x;

	}

	return gcd(y, x % y);

}



ll com_mod(ll n, ll k, ll m) {

	if (k == 0) return 1;

	else {

		ll x = 1;

		ll y = 1;

		for (ll i = 0; i < k; i++) {

			x = (x * (n - i)) % m;

			y = (y * (i + 1)) % m;

		}

		ll res = (x * pow_mod(y, m - 2, m)) % m;

		return res;

	}

}



int main() {

	int m; cin >> m;

	cout << 48 - m << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2720354252102615x):
#include<stdio.h>

int main() {

	int m; scanf("%d", &m);

	printf("%d", 48 - m);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int maxn = 100 * 1000 + 20;

int n, m, dis[maxn];

vector <int> adj[maxn], adjexit[maxn];

bool vis[maxn];



void input() {

    cin >> n >> m;

    for (int i = 0, a, b; i < m; i++) {

        cin >> a >> b;

        adj[a].push_back(b);

        adj[b].push_back(a);

    }

}



void dfs(int v) {

    vis[v] = 1;

    for (int u : adj[v]) {

        if (!vis[u]) {

            dis[u] = dis[v] + 1;

            dfs(u);

            adjexit[u].size() % 2? adjexit[u].push_back(v): adjexit[v].push_back(u);

        }

        else if (dis[v] < dis[u])

            adjexit[v].push_back(u);

    }

}

void output() {

    for (int i = 1; i <= n; i++)

        for (int j : adjexit[i])

            cout << i << ' ' << j << endl;

}

int main() {    

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

    input();

    if (m % 2)

        return cout << -1 << endl, 0;

    dfs(1);

    output();

    return 0;    

}




// Faster C++ solution for the same problem (measured speedup: 6.538004530356671x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

struct E {

  int v;

  bool vis;

  E *next, *rev;

};



const int N = 100010;



int n, m;

bool vis[N], par[N];

E* g[N];



E* adde(int u, int v) {

  static E pool[N * 2], *p = pool;

  ++p;

  p->v = v;

  p->next = g[u];

  g[u] = p;

  return p;

}



void dfs(int u) {

  vis[u] = true;

  for (E* p = g[u]; p; p = p->next)

    if (!p->vis) {

      p->vis = p->rev->vis = true;

      if (!vis[p->v]) {

        dfs(p->v);

        if (par[p->v]) {

          printf("%d %d\n", p->v, u);

        } else {

          printf("%d %d\n", u, p->v);

          par[u] ^= 1;

        }

      } else {

        printf("%d %d\n", u, p->v);

        par[u] ^= 1;

      }

    }

}



int main() {

  scanf("%d%d", &n, &m);

  if (m % 2) {

    puts("-1");

    return 0;

  }

  while (m--) {

    int u, v;

    scanf("%d%d", &u, &v);

    E *p = adde(u, v), *q = adde(v, u);

    p->rev = q;

    q->rev = p;

  }

  dfs(1);

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1000 * 100 + 20;

vector <int> gr[maxn], ans[maxn];

int n, m, vis[maxn];

void dfs(int v, int u) {

	vis[v] = 1;

	for (int i: gr[v]) {

		if (!vis[i]) {

			dfs(i , v);

			if (ans[i].size() % 2)

				ans[i].push_back(v);

			else

				ans[v].push_back(i);

			

		}

		else if (i != u) {

			if (i > v)

				ans[v].push_back(i);

		}

	}

}

int main() {

	cin >> n >> m;

	for (int i = 0; i < m; i++) {

		int a, b;

		cin >> a >> b;

		gr[a].push_back(b);

		gr[b].push_back(a);

	}

	

	if (m % 2)

		cout << -1 << endl;

	else {

		dfs(1, 0);

	}

	for (int i = 1; i <= n; i++)

		for (int j: ans[i])

			cout << i << " " << j << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.518602857850655x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

struct E {

  int v;

  bool vis;

  E *next, *rev;

};



const int N = 100010;



int n, m;

bool vis[N], par[N];

E* g[N];



E* adde(int u, int v) {

  static E pool[N * 2], *p = pool;

  ++p;

  p->v = v;

  p->next = g[u];

  g[u] = p;

  return p;

}



void dfs(int u) {

  vis[u] = true;

  for (E* p = g[u]; p; p = p->next)

    if (!p->vis) {

      p->vis = p->rev->vis = true;

      if (!vis[p->v]) {

        dfs(p->v);

        if (par[p->v]) {

          printf("%d %d\n", p->v, u);

        } else {

          printf("%d %d\n", u, p->v);

          par[u] ^= 1;

        }

      } else {

        printf("%d %d\n", u, p->v);

        par[u] ^= 1;

      }

    }

}



int main() {

  scanf("%d%d", &n, &m);

  if (m % 2) {

    puts("-1");

    return 0;

  }

  while (m--) {

    int u, v;

    scanf("%d%d", &u, &v);

    E *p = adde(u, v), *q = adde(v, u);

    p->rev = q;

    q->rev = p;

  }

  dfs(1);

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



const int MAX_N = int(1e5) + 10;



int n, m, ans_top;

std::vector<int> edges[MAX_N], tree[MAX_N];

std::pair<int, int> el[MAX_N], ans[MAX_N];

int par[MAX_N], deg[MAX_N];

bool in[MAX_N];



void dfs(int x, int p) {

	for (auto y : tree[x]) {

		if (y != p) {

			dfs(y, x);

		}

	}

	if (x == 1) return;

	if (deg[x] & 1) {

		ans[++ans_top] = std::make_pair(x, p);

		++deg[x];

	} else {

		ans[++ans_top] = std::make_pair(p, x);

		++deg[p];

	}

}



int find(int x) {

	return x == par[x] ? x : par[x] = find(par[x]);

}



void solve() {

	for (int i = 1; i <= n; ++i) {

		par[i] = i;

	}

	int tot = 0;

	for (int i = 1; i <= m; ++i) {

		int x = el[i].first, y = el[i].second;

		x = find(x);

		y = find(y);

		if (x != y) {

			in[i] = true;

			tree[el[i].first].push_back(el[i].second);

			tree[el[i].second].push_back(el[i].first);

			par[y] = x;

			++tot;

			if (tot == n - 1) break;

		}

	}

	ans_top = 0;

	for (int i = 1; i <= m; ++i) {

		if (!in[i]) {

			ans[++ans_top] = el[i];

			++deg[el[i].first];

		}

	}

	dfs(1, 0);

}



int main() {

	scanf("%d%d", &n, &m);

	if (m & 1) {

		puts("-1");

		return 0;

	}

	for (int i = 1; i <= m; ++i) {

		int x, y;

		scanf("%d%d", &x, &y);

		edges[x].push_back(y);

		edges[y].push_back(x);

		el[i] = std::make_pair(x, y);

	}



	solve();

	for (int i = 1; i <= m; ++i) {

		printf("%d %d\n", ans[i].first, ans[i].second);

	}

}

// Faster C++ solution for the same problem (measured speedup: 6.4856709155736265x):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef unsigned long long ull;

struct E {

  int v;

  bool vis;

  E *next, *rev;

};



const int N = 100010;



int n, m;

bool vis[N], par[N];

E* g[N];



E* adde(int u, int v) {

  static E pool[N * 2], *p = pool;

  ++p;

  p->v = v;

  p->next = g[u];

  g[u] = p;

  return p;

}



void dfs(int u) {

  vis[u] = true;

  for (E* p = g[u]; p; p = p->next)

    if (!p->vis) {

      p->vis = p->rev->vis = true;

      if (!vis[p->v]) {

        dfs(p->v);

        if (par[p->v]) {

          printf("%d %d\n", p->v, u);

        } else {

          printf("%d %d\n", u, p->v);

          par[u] ^= 1;

        }

      } else {

        printf("%d %d\n", u, p->v);

        par[u] ^= 1;

      }

    }

}



int main() {

  scanf("%d%d", &n, &m);

  if (m % 2) {

    puts("-1");

    return 0;

  }

  while (m--) {

    int u, v;

    scanf("%d%d", &u, &v);

    E *p = adde(u, v), *q = adde(v, u);

    p->rev = q;

    q->rev = p;

  }

  dfs(1);

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define fi first

#define se second

using namespace std;

long long n,m;

const long long N=1e5+5;

bool vs[N];

vector<long long> adj[N];

vector<long long> nadj[N];

vector<pair<long long,long long> > ans;

long long odd[N];

vector<pair<long long, long long> > inp;

map<long long, map<long long, long long> > edge;

void dfs(long long e){

	vs[e]=true;

	for(auto x: adj[e]){

		if(vs[x]==false){

			edge[e][x]=1;

			edge[x][e]=1;

			dfs(x);

			nadj[e].push_back(x);

		}

	}

}

void DFS(long long e, long long par){

	vs[e]=true;

	for(auto x: nadj[e]){

		DFS(x,e);

	}

	if(odd[e]==0&&e!=1){

		odd[par] = (odd[par]+1)%2;

		ans.push_back({par,e});

	}

	else if(e!=1&&odd[e]==1){

		odd[e] = (odd[e]+1)%2;

		ans.push_back({e,par});

	}

}

signed main(){

	cin >> n >> m;

	for(int i=1;i<=m;i++){

		long long a,b;

		cin >> a >> b;

		adj[a].push_back(b);

		adj[b].push_back(a);

		inp.push_back({a,b});

	}

	if(m%2==1){

		cout << "-1";

		return 0;

	}

	dfs(1);

	for(auto x:inp){

		if(edge[x.fi][x.se]==0){

			odd[x.fi] = (odd[x.fi]+1)%2;

			ans.push_back({x.fi,x.se});

		}

	}

	memset(vs,false,sizeof(vs));

	DFS(1,1);

	if(odd[1]==1){

		cout << "-1";

	}

	else{

		for(auto x : ans){

			cout << x.fi << " " << x.se<<endl;

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.8096771051390617x):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

const int maxn=1e5+1000;

using namespace std;

int n,m,fa[maxn],out[maxn];

vector<int>side[maxn];

int get(int x){

	if(fa[x]==x)return x;

	fa[x]=get(fa[x]);

	return fa[x];	

}

void uni(int x,int y){

	fa[get(x)]=get(y);	

}

void dfs(int now,int fa){

	for(int i=0;i<side[now].size();i++){

		int v=side[now][i];if(v==fa)continue;

		dfs(v,now);

		if(out[v]&1){printf("%d %d\n",v,now);}

		else{out[now]++;printf("%d %d\n",now,v);}	

	}

	return;

}

int main(){

	scanf("%d%d",&n,&m);

	if(m&1){printf("-1");return 0;}

	for(int i=1;i<=n;i++)fa[i]=i;

	for(int i=1;i<=m;i++){

		int u,v;scanf("%d%d",&u,&v);

		if(get(u)!=get(v)){side[u].push_back(v);side[v].push_back(u);uni(u,v);}

		else{

			out[v]++;

			printf("%d %d\n",v,u);

		}

	}//

	dfs(1,0);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define fi first

#define se second

const int N=1e5+5;

int n,m,u[N],v[N],check[N],deg[N];

vector<pair<int,int> > ans;

vector<int> adj[N];

map<pair<int,int>,int> dir;

void dfs(int u,int p){

	check[u]=1;

	for(int v: adj[u]){

		if(check[v]==0){

			dfs(v,u);

		}

	}

	if(deg[u]%2==1){

		if(dir[{u,p}]==1){

			dir[{u,p}]=0;

			dir[{p,u}]=1;

			deg[u]--;

			deg[p]++;

		}else{

			dir[{u,p}]=1;

			dir[{p,u}]=0;

			deg[u]++;

			deg[p]--;

		}

	}

}

int main(){

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

	cin>>n>>m;

	for(int i=1;i<=m;i++){

		cin>>u[i]>>v[i];

		adj[u[i]].push_back(v[i]);

		adj[v[i]].push_back(u[i]);

		dir[{u[i],v[i]}]=1;

		deg[u[i]]++;

	}

	if(m%2==1){

		cout<<"-1";

		return 0;

	}

	dfs(1,1);

	for(int i=1;i<=m;i++){

		if(dir[{u[i],v[i]}]==1){

			cout<<u[i]<<" "<<v[i]<<endl;

		}else{

			cout<<v[i]<<" "<<u[i]<<endl;

		}

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.9890730879299516x):
#include<iostream>

#include<algorithm>

#include<cstring>

#include<cstdio>

using namespace std;

#define MAXN 200006

int n , m;



int head[MAXN] , to[MAXN << 1] , nex[MAXN << 1] , ecn = -1;

void ade( int u , int v ) {

	to[++ecn] = v , nex[ecn] = head[u] , head[u] = ecn;

}

int fa[MAXN];

int find( int x ) {

	return fa[x] == x ? x : fa[x] = find( fa[x] );

}

struct e{ int u , v; } E[MAXN];

int tt[MAXN] , deg[MAXN];

void dfs( int u , int fa , int ee ) {

	for( int i = head[u] ; ~ i ; i = nex[i] ) {

		int v = to[i];

		if( v == fa ) continue;

		dfs( v , u , i );

	}

	if( u == 1 ) return;

	if( deg[u] ) {

		deg[u] ^= 1;

		if( ~ ee & 1 ) 

			swap( E[tt[ee >> 1]].u , E[tt[ee >> 1]].v );

	} else {

		deg[fa] ^= 1;

		if( ee & 1 ) 

			swap( E[tt[ee >> 1]].u , E[tt[ee >> 1]].v );

	}

}

int main() {

	memset( head , -1 , sizeof head );

	cin >> n >> m;

	if( m & 1 ) return puts("-1") , 0;

	for( int i = 1 ; i <= n ; ++ i ) fa[i] = i;

	for( int i = 1 , u , v ; i <= m ; ++ i ) {

		scanf("%d%d",&u,&v);

		E[i] = ( e ) { u , v };

		if( find( u ) != find( v ) ) {

			ade( u , v ) , ade( v , u );

			tt[ecn >> 1] = i;

			fa[find( u )] = find( v );

		} else {

			deg[u] ^= 1;

		}

	}

	dfs( 1 , 1 , 0 );

	for( int i = 1 ; i <= m ; ++ i ) printf("%d %d\n",E[i].u , E[i].v);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



//#pragma GCC optimize("O3")

//#pragma GCC target("sse4")



#define FOR(i, a, b) for(int i = (a); i < (b); ++i)

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



#define SZ(a) (int)((a).size())

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = (LL)INF * INF;



const int MAX = 1 << 17;



vector<int> g[MAX];

bool used[MAX];

bool cnt[MAX];

vector<PII> ans;

int dep[MAX];



void dfs(int v, int p)

{

	used[v] = true;

	for(int to: g[v])

	{

		if(used[to] && to != p && dep[to] < dep[v])

		{

			ans.PB(MP(v, to));

			cnt[v] ^= 1;

		}

		if(!used[to])

		{

			dep[to] = dep[v] + 1;

			dfs(to, v);

			if(cnt[to])

				ans.PB(MP(to, v));

			else

			{

				ans.PB(MP(v, to));

				cnt[v] ^= 1;

			}

		}

	}

}



int main()

{

	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m;

	cin >> n >> m;

	if(m & 1)

	{

		cout << -1;

		return 0;

	}

	FOR(i, 0, m)

	{

		int u, v;

		cin >> u >> v;

		u--;

		v--;

		g[u].PB(v);

		g[v].PB(u);

	}

	dfs(0, -1);

	assert(SZ(ans) == m);

	for(auto e: ans)

		cout << e.first + 1 << " " << e.second + 1 << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.225577152961823x):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<cmath>

#include<vector>

const int maxn=1e5+1000;

using namespace std;

int n,m,fa[maxn],out[maxn];

vector<int>side[maxn];

int get(int x){

	if(fa[x]==x)return x;

	fa[x]=get(fa[x]);

	return fa[x];	

}

void uni(int x,int y){

	fa[get(x)]=get(y);	

}

void dfs(int now,int fa){

	for(int i=0;i<side[now].size();i++){

		int v=side[now][i];if(v==fa)continue;

		dfs(v,now);

		if(out[v]&1){printf("%d %d\n",v,now);}

		else{out[now]++;printf("%d %d\n",now,v);}	

	}

	return;

}

int main(){

	scanf("%d%d",&n,&m);

	if(m&1){printf("-1");return 0;}

	for(int i=1;i<=n;i++)fa[i]=i;

	for(int i=1;i<=m;i++){

		int u,v;scanf("%d%d",&u,&v);

		if(get(u)!=get(v)){side[u].push_back(v);side[v].push_back(u);uni(u,v);}

		else{

			out[v]++;

			printf("%d %d\n",v,u);

		}

	}

	dfs(1,0);

	return 0;

}