#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, m;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    long long int c = 0, f = 0, s = 0, mi = INT_MAX, a;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cin >> a;
        if (a == 0) f = 1;
        if (a < 0) c++;
        mi = min(mi, abs(a));
        s += abs(a);
      }
    }
    if (f == 1 || c % 2 == 0) {
      cout << s;
    } else
      cout << s - 2 * mi;
    cout << "\n";
  }
  return 0;
}
