#include <bits/stdc++.h>
struct Edge {
  int s, t, next;
} e[1000001];
int cnt, cur;
int head[100001], num[100001], f[100001];
int res[1000001];
void init(int n) {
  cur = 0;
  cnt = n;
  memset(head + 1, -1, sizeof(int) * n);
  memset(num + 1, 0, sizeof(int) * n);
  for (int i = 1; i <= n; i++) f[i] = i;
}
int getFather(int i) {
  if (f[i] == i) return i;
  return f[i] = getFather(f[i]);
}
void addEdge(int s, int t) {
  e[cur] = {s, t, head[s]};
  head[s] = cur++;
  num[s]++;
  num[t]--;
  f[getFather(s)] = getFather(t);
}
void addEdge2(int s, int t) {
  e[cur] = {s, t, head[s]};
  head[s] = cur++;
  e[cur] = {t, s, head[t]};
  head[t] = cur++;
  num[s]++;
  num[t]++;
  f[getFather(s)] = getFather(t);
}
int check() {
  int fa = getFather(e[0].s), k = 0, ret = 0;
  for (int i = cnt; i; i--) {
    if (head[i] != -1 && getFather(i) != fa) return -1;
    if (num[i] == 1 || num[i] == -1) {
      if (++k > 2) return -1;
      if (num[i] == 1) ret = i;
    } else if (num[i])
      return -1;
  }
  return ret;
}
void euler(int i) {
  static int pos[100001], s[1000001];
  static bool used[1000001];
  int top = 0, j = 0, k = head[i];
  memcpy(pos + 1, head + 1, sizeof(int) * cnt);
  memset(used, 0, sizeof(bool) * cur);
  while (1) {
    while (k != -1 && used[k]) k = e[k].next;
    if (k != -1) {
      used[k] = true;
      used[k ^ 1] = true;
      s[top++] = k;
      pos[e[k].s] = e[k].next;
      k = pos[e[k].t];
      continue;
    }
    if (--top < 0) return;
    res[j++] = s[top];
    k = pos[e[s[top]].s];
  }
}
int main() {
  int test, n, m;
  scanf("%d", &test);
  while (test--) {
    scanf("%d%d", &n, &m);
    init(n);
    for (int i = 0; i < m; i++) {
      int s, t;
      scanf("%d%d", &s, &t);
      addEdge2(s, t);
    }
    int tmp = 0, ans = 0;
    for (int i = 1; i <= n; i++) {
      if (num[i] & 1) {
        if (!tmp)
          tmp = i;
        else {
          addEdge2(tmp, i);
          tmp = 0;
          ans++;
        }
      }
    }
    tmp = 1;
    for (int i = 1; i <= n; i++) {
      if (getFather(i) != getFather(tmp)) {
        addEdge2(tmp, i);
        tmp = i;
      }
    }
    if (tmp != 1) addEdge(tmp, 1);
    euler(1);
    printf("%d\n", n - 2 * ans);
    for (int i = 0; i * 2 < cur; i++) {
      if (res[i] < 2 * m) printf("%d %d\n", e[res[i]].s, e[res[i]].t);
    }
  }
}
