#include <bits/stdc++.h>
typedef int arr[(40010)];
arr next, v, be, deg, used;
int ans[(40010)][2];
void adde(int a, int b, int id) {
  next[id] = be[a];
  be[a] = id;
  v[id] = b;
}
void dfs(int st) {
  for (int i = be[st], j; i; i = next[i]) {
    if (!used[j = i >> 1]) {
      deg[ans[j][0] = st]--;
      deg[ans[j][1] = v[i]]--;
      used[j] = 1;
      be[st] = next[i];
      dfs(v[i]);
      break;
    }
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, m, tot = 0;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) be[i] = 0;
    for (int i = 1, a, b; i <= m; i++) {
      scanf("%d%d", &a, &b);
      adde(a, b, i << 1);
      adde(b, a, i << 1 | 1);
      used[i] = 0;
      deg[a]++;
      deg[b]++;
    }
    for (int i = 1; i <= n; i++) tot += !(deg[i] & 1);
    for (int i = 1; i <= n; i++)
      if (deg[i] & 1) {
        while (deg[i] > 0) dfs(i);
      }
    for (int i = 1; i <= n; i++) {
      while (deg[i] > 0) dfs(i);
    }
    printf("%d\n", tot);
    for (int i = 1; i <= m; i++) {
      printf("%d %d\n", ans[i][0], ans[i][1]);
    }
  }
}
