#include <bits/stdc++.h>
using namespace std;
void testcase() {
  int m, n;
  cin >> m >> n;
  int sum = 0, cnt = 0, minVal = INT_MAX;
  vector<vector<int>> v(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> v[i][j];
      sum += abs(v[i][j]);
      minVal = min(minVal, abs(v[i][j]));
      if (v[i][j] < 0) cnt++;
    }
  }
  if (cnt & 1) sum -= (2 * minVal);
  cout << sum << endl;
}
signed main() {
  int t;
  cin >> t;
  while (t--) testcase();
}
