#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int tests = 1;
  cin >> tests;
  while (tests--) {
    long long int n, m, x, sum = 0;
    cin >> n >> m;
    long long int mn = INT_MAX;
    long long int neg = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> x;
        if (x < 0) neg++;
        mn = min(mn, abs(x));
        sum += abs(x);
      }
    }
    if (neg & 1) sum -= (2 * mn);
    cout << sum << "\n";
  }
  return 0;
}
