#include <bits/stdc++.h>
using namespace std;
vector<bool> visited;
vector<vector<pair<int, int>>> graph;
vector<bool> marked;
vector<int> order;
void dfs(int u) {
  visited[u] = true;
  for (auto p : graph[u]) {
    if (!marked[p.second]) {
      marked[p.second] = true;
      dfs(p.first);
    }
  }
  order.push_back(u);
}
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  visited = vector<bool>(n + 1, false);
  graph = vector<vector<pair<int, int>>>(n + 1);
  marked = vector<bool>(n + m, false);
  vector<int> deg(n + 1, 0);
  int i, j, u, v, e;
  e = 0;
  for (i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    u--;
    v--;
    deg[u]++;
    deg[v]++;
    graph[u].push_back({v, e});
    graph[v].push_back({u, e});
    e++;
  }
  int c = 0;
  for (i = 0; i < n; i++) {
    if (deg[i] % 2 == 0) {
      c++;
    } else {
      graph[i].push_back({n, e});
      graph[n].push_back({i, e});
      e++;
    }
  }
  printf("%d\n", c);
  for (i = 0; i < n + 1; i++) {
    if (!visited[i]) {
      order.clear();
      dfs(i);
      for (j = 0; j < order.size() - 1; j++) {
        if (order[j] != n && order[j + 1] != n) {
          printf("%d %d\n", order[j] + 1, order[j + 1] + 1);
        }
      }
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t > 0) {
    t--;
    solve();
  }
  return 0;
}
