#define N 200007 int hd[N], tot = 1; bool vis[N], used[N]; structedge {int to, nxt;} e[N << 1]; vector<tii> ans;
voiddfs(int u, int fa){ vis[u] = true; int faid = 0; for (int i = hd[u], v; i; i = e[i].nxt) if (!vis[v = e[i].to]) dfs(v, u); elseif (v == fa) faid = (i >> 1); int lstid = 0, lstv = 0; for (int i = hd[u], v, id; i; i = e[i].nxt) if ((v = e[i].to) != fa && !used[id = (i >> 1)]) { if (lstid) { used[lstid] = used[id] = true; ans.eb(lstv, u, v); lstid = lstv = 0; } else {lstid = id; lstv = v;} } if (lstid && faid) { used[lstid] = used[faid] = true; ans.eb(lstv, u, fa); } }
intmain(){ int n = rd(), m = rd(); for (int i = 1; i <= m; ++i) { int u = rd(), v = rd(); e[++tot].to = v; e[tot].nxt = hd[u]; hd[u] = tot; e[++tot].to = u; e[tot].nxt = hd[v]; hd[v] = tot; } for (int i = 1; i <= n; ++i) if (!vis[i]) dfs(i, i); printf("%d\n", (int)ans.size()); for (auto [u, v, w] : ans) printf("%d %d %d\n", u, v, w); return0; }