#include <bits/stdc++.h>
using namespace std;
int edgenum, head[100005], vet[200005], nex[200005], val[200005], in[100005], n,
    m, ans;
vector<int> V;
bool vis[100005], used[100005];
void addedge(int u, int v, int w) {
  edgenum++, vet[edgenum] = v, nex[edgenum] = head[u], val[edgenum] = w,
             in[v]++, head[u] = edgenum;
}
void dfs_fleury(int u) {
  used[u] = 1;
  for (int i = head[u]; i != 0; i = nex[i]) {
    if (!vis[(i + 1) / 2]) {
      int v = vet[i];
      vis[(i + 1) / 2] = 1;
      if (val[i]) printf("%d %d\n", u, v);
      dfs_fleury(v);
    }
  }
}
int main() {
  int cas;
  scanf("%d", &cas);
  while (cas--) {
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n + 1; i++) used[i] = in[i] = head[i] = 0;
    edgenum = 0, V.clear(), memset(vis, 0, sizeof(vis));
    for (int i = 1, x, y; i <= m; i++)
      scanf("%d%d", &x, &y), addedge(x, y, 1), addedge(y, x, 1);
    ans = 0;
    for (int i = 1; i <= n; i++)
      if (in[i] & 1)
        V.push_back(i);
      else
        ans++;
    for (int i = 0; i + 1 < V.size(); i += 2)
      addedge(V[i], V[i + 1], 0), addedge(V[i + 1], V[i], 0);
    printf("%d\n", ans);
    for (int i = 1; i <= n; i++)
      if (!used[i]) dfs_fleury(i);
  }
  return 0;
}
