#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    int sum = 0, mn = 100000, pos = 0, neg = 0, zero = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int x;
        cin >> x;
        sum += abs(x);
        if (x < 0) neg++;
        if (x > 0) pos++;
        if (x == 0) zero++;
        mn = min(mn, abs(x));
        v.push_back(x);
      }
    }
    if (neg & 1 && zero == 0) {
      cout << sum - mn - mn << endl;
    } else {
      cout << sum << endl;
    }
  }
  return 0;
}
