#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    vector<pair<int, int> > ans, ed;
    set<int> s[205];
    int n, m, d[205] = {0};
    cin >> n >> m;
    for (int i = 0; i <= m - 1; i++) {
      int a, b;
      cin >> a >> b;
      ed.push_back(make_pair(a, b));
      s[a].insert(b);
      s[b].insert(a);
    }
    for (int i = 0; i <= m - 1; i++) {
      int a = ed[i].first, b = ed[i].second;
      if (!(s[a].find(b) != s[a].end())) continue;
      d[a]++;
      d[b]--;
      ans.push_back(make_pair(a, b));
      s[a].erase(s[a].find(b));
      s[b].erase(s[b].find(a));
      while (1) {
        if (s[a].empty() && s[b].empty()) break;
        if (!s[a].empty()) {
          int kk = *s[a].begin();
          d[a]--;
          d[kk]++;
          s[a].erase(s[a].find(kk));
          s[kk].erase(s[kk].find(a));
          ans.push_back(make_pair(kk, a));
          a = kk;
          if (a == b) break;
        }
        if (!s[b].empty()) {
          int kk = *s[b].begin();
          d[b]++;
          d[kk]--;
          s[b].erase(s[b].find(kk));
          s[kk].erase(s[kk].find(b));
          ans.push_back(make_pair(b, kk));
          b = kk;
          if (a == b) break;
        }
      }
    }
    int an = 0;
    for (int i = 1; i <= n; i++)
      if (d[i] == 0) an++;
    cout << an;
    cout << "\n";
    for (__typeof(ans.begin()) it = ans.begin(); it != ans.end(); it++) {
      cout << it->first << " " << it->second;
      cout << "\n";
    }
  }
  return 0;
}
