#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long inf = 1e9;
ll n, m, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    vector<int> v;
    int ans = 0;
    int sa = 0;
    bool z = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int x;
        cin >> x;
        if (!x) z = 1;
        v.push_back(abs(x));
        sa += (x < 0);
      }
    }
    if (z) {
      for (auto x : v) {
        ans += x;
      }
      cout << ans << "\n";
      continue;
    }
    sort(v.begin(), v.end());
    z = sa % 2;
    if (z) {
      ans -= v[0] * 2;
    }
    for (auto x : v) {
      ans += x;
    }
    cout << ans << "\n";
  }
  return 0;
}
