#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > edges;
vector<set<int> > g;
set<int> removed;
void FindEulerPath(int u, vector<pair<int, pair<int, int> > >& res) {
  for (int edge_index : g[u]) {
    pair<int, int> edge = edges[edge_index];
    if (removed.count(edge_index) == 1) {
      continue;
    }
    int v = edge.second == u ? edge.first : edge.second;
    removed.insert(edge_index);
    FindEulerPath(v, res);
    res.push_back({edge_index, {u, v}});
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int tests_count;
  cin >> tests_count;
  while (tests_count--) {
    edges.clear();
    g.clear();
    removed.clear();
    int n, m;
    cin >> n >> m;
    g.resize(n);
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      --u;
      --v;
      g[u].insert(edges.size());
      g[v].insert(edges.size());
      edges.push_back({u, v});
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += g[i].size() % 2 == 0;
    }
    while (true) {
      bool ok = true;
      for (int u = 0; u < n && ok; ++u) {
        for (int v = u + 1; v < n && ok; ++v) {
          if (g[u].size() % 2 == 1 && g[v].size() % 2 == 1) {
            ok = false;
            g[u].insert(edges.size());
            g[v].insert(edges.size());
            edges.push_back({u, v});
          }
        }
      }
      if (ok) {
        break;
      }
    }
    vector<pair<int, pair<int, int> > > res;
    for (int i = 0; i < n; ++i) {
      FindEulerPath(i, res);
    }
    cout << cnt << '\n';
    for (int i = 0; i < res.size(); ++i) {
      if (res[i].first < m) {
        cout << res[i].second.first + 1 << ' ' << res[i].second.second + 1
             << '\n';
      }
    }
  }
  return 0;
}
