#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, X = 0, sum = 0, min_elem = INT_MAX;
  cin >> n >> m;
  vector<vector<int> > a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      min_elem = min(min_elem, abs(a[i][j]));
      sum += abs(a[i][j]);
      if (a[i][j] < 0) X++;
    }
  }
  if (X % 2 == 0)
    cout << sum;
  else
    cout << sum - 2 * min_elem;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
