#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, a, mn = 1e9, sum = 0, cneg = 0;
    cin >> n >> m;
    for (int x = 0; x < n * m; x++) {
      cin >> a;
      if (a < 0) cneg++;
      sum += abs(a);
      mn = min(mn, abs(a));
    }
    if (cneg & 1)
      cout << sum - (mn * 2) << endl;
    else
      cout << sum << endl;
  }
  return 0;
}
