#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e3 + 7;
const long long mod = 1e9 + 7;
const long long INF = 1e9 + 7;
const long long mlog = 20;
const long long SQ = 400;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    set<long long> adj[maxn];
    for (long long i = 0; i < m; i++) {
      long long u, v;
      cin >> u >> v;
      adj[u].insert(v), adj[v].insert(u);
    }
    for (long long i = 1; i <= n; i++)
      if (adj[i].size() % 2 == 1) adj[i].insert(0), adj[0].insert(i);
    cout << n - adj[0].size() << "\n";
    for (long long i = 0; i <= n; i++) {
      while (!adj[i].empty()) {
        long long v = *adj[i].begin();
        if (i && v) cout << i << " " << v << "\n";
        adj[i].erase(v), adj[v].erase(i);
        i = v;
      }
    }
  }
  return 0;
}
