#include <bits/stdc++.h>
using namespace std;
void solveD() {
  long long int n, i, j, k, l, q, p, m;
  cin >> n >> m;
  p = 1e16;
  q = 0;
  l = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> k;
      q += abs(k);
      p = min(p, abs(k));
      if (k < 0) {
        l++;
      }
    }
  }
  if (l % 2) {
    q -= 2 * p;
  }
  cout << q << "\n";
}
int main() {
  long long int t = 1;
  cin >> t;
  long long int c = 1;
  while (t--) {
    solveD();
    c++;
  }
  return 0;
}
