#include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> N >> M;
    int p = 0;
    vector<int> n;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) {
        int x;
        cin >> x;
        n.push_back(x);
        if (x < 0) cnt++;
      }
    }
    sort(n.begin(), n.end(), greater<int>());
    int mn = 10000;
    for (auto x : n) {
      mn = min(mn, abs(x));
      p += abs(x);
    }
    if (cnt % 2 == 0)
      cout << p << '\n';
    else
      cout << p - mn - mn << '\n';
  }
  return 0;
}
