#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
void dfs(vector<set<int>> &g, int u, vector<int> &mark, vector<int> &odd) {
  mark[u] = 1;
  if (g[u].size() % 2 == 1) odd.push_back(u);
  for (auto v : g[u]) {
    if (mark[v]) continue;
    dfs(g, v, mark, odd);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m, ct;
    cin >> n >> m;
    ct = n;
    vector<set<int>> g(n + 2), odd;
    vector<int> mark(n + 2, 0), deg(n + 2, 0);
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      g[u].insert(v);
      ++deg[u];
      g[v].insert(u);
      ++deg[v];
      if (deg[u] % 2 == 0)
        ++ct;
      else
        --ct;
      if (deg[v] % 2 == 0)
        ++ct;
      else
        --ct;
    }
    cout << ct << '\n';
    for (int i = 1; i <= n; ++i) {
      if (mark[i]) continue;
      vector<int> cur;
      dfs(g, i, mark, cur);
      int k = cur.size();
      for (int j = 0; j < k; ++j) {
        g[cur[j]].insert(n + 1);
        g[n + 1].insert(cur[j]);
      }
      stack<int> head;
      vector<int> cycle;
      head.push(i);
      while (!head.empty()) {
        int u = head.top();
        while (!g[u].empty()) {
          int v = *g[u].begin();
          g[u].erase(v);
          g[v].erase(u);
          head.push(v);
          u = head.top();
        }
        while (!head.empty() and g[u].empty()) {
          cycle.push_back(u);
          head.pop();
          if (head.empty()) break;
          u = head.top();
        }
      }
      k = cycle.size();
      for (int j = 0; j < k; ++j) {
        int u = cycle[j], v = cycle[(j + 1) % k];
        if ((u != v) and u != n + 1 and v != n + 1)
          cout << u << ' ' << v << '\n';
      }
      k = cur.size();
      for (int j = 0; j < k; ++j) {
        g[cur[j]].erase(n + 1);
        g[n + 1].erase(cur[j]);
      }
    }
  }
}
