#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, m, cnt = 0, num_odd, ver_dummy;
vector<long long> Euler, odd;
bool vs[N], tham[N];
vector<pair<long long, long long> > a[N];
void in() {
  cin >> n >> m;
  odd.clear();
  cnt = 0;
  for (long long i = 1; i <= n + 1; i++) a[i].clear();
  memset(tham, 0, sizeof(tham));
  memset(vs, 0, sizeof(vs));
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v;
    a[u].push_back({v, i}), a[v].push_back({u, i});
  }
  ver_dummy = n + 1;
  for (long long i = 1; i <= n; i++)
    if (a[i].size() % 2 != 0) odd.push_back(i);
  long long dem = m;
  for (auto i : odd) {
    a[ver_dummy].push_back({i, ++dem});
    a[i].push_back({ver_dummy, dem});
  }
}
void Euler_cycle(long long x) {
  tham[x] = true;
  for (auto i : a[x]) {
    long long y = i.first, id = i.second;
    if (!vs[id]) {
      vs[id] = true;
      Euler_cycle(y);
    }
  }
  Euler.push_back(x);
}
void process() {
  cout << n - odd.size() << '\n';
  for (long long i = 1; i <= n; i++) {
    if (!tham[i]) {
      Euler.clear();
      Euler_cycle(i);
      vector<pair<long long, long long> > res;
      for (long long j = 0; j < Euler.size() - 1; j++) {
        if (Euler[j] == n + 1 || Euler[j + 1] == n + 1) continue;
        res.push_back({Euler[j], Euler[j + 1]});
      }
      for (auto i : res) cout << i.first << ' ' << i.second << '\n';
    }
  }
}
int main() {
  if (fopen("trash.inp", "r"))
    freopen("trash.inp", "r", stdin), freopen("trash.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    in();
    process();
  }
}
