#include <bits/stdc++.h>
using namespace std;
inline int nxt() {
  int x;
  cin >> x;
  return x;
}
int solve() {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  int abssum = 0;
  int black = 0, white = 0;
  int minabs = 999999;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      abssum += abs(a[i][j]);
      minabs = min(minabs, abs(a[i][j]));
      if (a[i][j] < 0) {
        if (i + j % 2)
          black ^= 1;
        else
          white ^= 1;
      }
    }
  }
  if (black != white) abssum -= 2 * minabs;
  cout << abssum << '\n';
  return 0;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
}
