#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m, a, b = inf, s = 0, c = 0;
    cin >> n >> m;
    for (long long i = 0; i < n * m; i++) {
      cin >> a;
      s += abs(a);
      b = min(abs(a), b);
      if (a < 0) c++;
    }
    if (c % 2 == 1) s = s - 2 * b;
    cout << s << endl;
  }
  return 0;
}
