#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll M = 1e9 + 7;
const int N = 5050;
void solve() {
  int n, m;
  cin >> n >> m;
  bool ok = false;
  int mi = INT_MAX;
  int cnt = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int tmp;
      cin >> tmp;
      if (tmp == 0) ok = true;
      if (tmp < 0) cnt++;
      sum += abs(tmp);
      mi = min(mi, abs(tmp));
    }
  }
  if (cnt & 1 == 1 && !ok) {
    cout << (sum - 2 * mi) << "\n";
    return;
  }
  cout << sum << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
