#include "bits/stdc++.h"
#define int long long
#define ull unsigned long long
#define PII pair<int, int>
#define TIII tuple<int, int, int>
#define LL __int128
#define eps 1e-6
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
constexpr int N = 2e6 + 10, M = 2e6 + 10, mod = 1e9 + 7, inf = 1e18;
int n, m;
void solve()
{
cin >> n >> m;
vector<int> a(n + 1);
vector<tuple<int, int, int>> ans;
for (int i = 1; i <= m; i++)
{
int u, v;
cin >> u >> v;
if (min(u, v) != 1)
{
ans.emplace_back(1, u, v);
}
a[u] ^= 1, a[v] ^= 1;
}
int pos = 0;
for (int i = 2; i <= n; i++)
{
if (a[i])
pos = i;
}
if (pos)
{
for (int i = 2; i <= n; i++)
{ `
if (!a[i])
{
ans.emplace_back(1, pos, i);
pos = i;
}
}
}
cout << ans.size() << endl;
for (auto [a, b, c] : ans)
{
cout << a << " " << b << " " << c << endl;
}
}
signed main()
{
std::ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cout << fixed << setprecision(2);
#ifndef ONLINE_JUDGE
freopen("in.txt", "rt", stdin);
freopen("out.txt", "wt", stdout);
#endif
int Cases = 1;
cin >> Cases;
while (Cases--)
{
solve();
}
fprintf(stderr, "Time : %.2lfs\n", clock() * 1.0 / CLOCKS_PER_SEC);
return 0;
}