#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e5 + 2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > edges(m);
    for (int i = int(0); i < int(m); ++i)
      cin >> edges[i].first >> edges[i].second;
    int high = -1;
    vector<pair<int, int> > key;
    for (int it = int(0); it < int(1000); ++it) {
      vector<int> in(n + 1, 0), out(n + 1, 0);
      vector<pair<int, int> > cur_edges(m);
      for (int i = int(0); i < int(m); ++i) {
        pair<int, int> edge = edges[i];
        if (rng() % 2) swap(edge.first, edge.second);
        cur_edges[i] = edge;
        in[edge.second]++;
        out[edge.first]++;
      }
      for (int i = int(0); i < int(m); ++i) {
        pair<int, int> edge = cur_edges[i];
        int from = edge.first, to = edge.second;
        if (out[from] > in[from] and in[to] > out[to]) {
          swap(edge.first, edge.second);
          cur_edges[i] = edge;
          in[from]++;
          out[from]--;
          in[to]--;
          out[to]++;
        }
      }
      int ans = 0;
      for (int i = int(1); i < int(n + 1); ++i)
        if (in[i] == out[i]) ans++;
      if (ans > high) {
        high = ans;
        key = cur_edges;
      }
    }
    cout << high << endl;
    for (auto x : key) cout << x.first << " " << x.second << endl;
  }
  return 0;
}
