#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t-- > 0) {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > out;
    int x, y;
    vector<vector<pair<int, bool> > > g(n + 2);
    for (int i = 0; i < m; ++i) {
      scanf("%d%d", &x, &y);
      g[x].push_back({y, 0});
      g[y].push_back({x, 0});
    }
    int ans = 0;
    vector<bool> used(n + 2);
    for (int it = 1; it <= n; ++it) {
      if (used[it]) continue;
      vector<int> conn;
      set<pair<int, int> > check;
      queue<int> q;
      q.push(it);
      used[it] = 1;
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        if (g[v].size() % 2 == 0)
          ans++;
        else
          conn.push_back(v);
        for (int i = 0; i < g[v].size(); ++i)
          if (!used[g[v][i].first]) {
            used[g[v][i].first] = 1;
            q.push(g[v][i].first);
          }
      }
      for (int i = 0; i < conn.size(); i += 2) {
        g[conn[i]].push_back({conn[i + 1], 0});
        g[conn[i + 1]].push_back({conn[i], 0});
        check.insert({conn[i], conn[i + 1]});
        check.insert({conn[i + 1], conn[i]});
      }
      stack<int> st;
      st.push(it);
      vector<int> res;
      while (!st.empty()) {
        int v = st.top();
        int x = -1;
        for (int i = 0; i < g[v].size(); ++i)
          if (!g[v][i].second) x = i;
        if (x == -1) {
          res.push_back(v);
          st.pop();
        } else {
          g[v][x].second = 1;
          int to = g[v][x].first;
          for (int i = 0; i < g[to].size(); ++i)
            if (g[to][i].first == v) {
              g[to][i].second = 1;
              break;
            }
          st.push(to);
        }
      }
      if (res.size() < 2) continue;
      for (int i = 0; i < res.size() - 1; ++i) {
        if (check.find({res[i], res[i + 1]}) == check.end())
          out.push_back({res[i], res[i + 1]});
        else {
          check.erase({res[i], res[i + 1]});
          check.erase({res[i + 1], res[i]});
        }
      }
    }
    cout << ans << endl;
    for (int i = 0; i < out.size(); ++i)
      printf("%d %d\n", out[i].first, out[i].second);
  }
  return 0;
}
