#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  long long s = 0;
  int p = 0;
  int x = INT_MAX;
  bool zero = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      if (a < 0) p++;
      s += abs(a);
      if (x > abs(a)) x = abs(a);
      if (a == 0 && !zero) zero = true;
    }
  }
  if (p % 2 == 1 && !zero) s -= 2 * abs(x);
  cout << s << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    solve();
  }
  return 0;
}
