/* @author: Praveen Dhinwa */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep1(i,a,b) for(int (i)=(a);(i)<=(int)(b);(i)++)
#define fore(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;
const int N = (int) 1e5 + 5;
vector <int> g[N];
set <pair <int, int> > blocked;
int dfs (int v) {
vector <int> adj;
for (int i = 0; i < g[v].size(); i++) if (blocked.find (make_pair (g[v][i], v)) == blocked.end()) adj.push_back(g[v][i]);
for (int i = 0; i < adj.size(); i++) {
int u = adj[i];
blocked.insert (make_pair (u, v));
blocked.insert (make_pair (v, u));
}
vector <int> unpaired;
for (int i = 0; i < adj.size(); i++) {
int u = adj[i];
int w = dfs (u);
if (w != 0) unpaired.push_back(w);
}
cout << unpaired.size() << endl;
for (int i = 0; i + 1 < unpaired.size(); i += 2) {
int u = unpaired[i], w = unpaired[i + 1];
printf ("%d %d %d\n", u, v, w);
}
if (unpaired.size() % 2 == 1) {
return unpaired[unpaired.size() - 1];
} else return 0;
}
int main() {
int n, m;
scanf ("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
int u, v;
scanf ("%d %d", &u, &v);
g[u].push_back (v);
g[v].push_back (u);
}
if (m & 1) cout << -1 << endl;
else dfs (1);
return 0;
}
LyogQGF1dGhvcjogUHJhdmVlbiBEaGlud2EgKi8KI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgTEw7CiNkZWZpbmUgcmVwKGksbikgZm9yKGludCAoaSk9MDsoaSk8KGludCkobik7KGkpKyspCiNkZWZpbmUgcmVwMShpLGEsYikgZm9yKGludCAoaSk9KGEpOyhpKTw9KGludCkoYik7KGkpKyspCiNkZWZpbmUgZm9yZShjLGl0cikgZm9yKF9fdHlwZW9mKChjKS5iZWdpbigpKSBpdHI9KGMpLmJlZ2lu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