#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int a[n][m], ans = 0, cnt = 0, sub = 1000;
    std::vector<long long int> odds;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cin >> a[i][j];
        sub = min(sub, abs(a[i][j]));
        ans += abs(a[i][j]);
        if (a[i][j] < 0) cnt++;
      }
    }
    if (cnt % 2) {
      ans -= 2 * sub;
    }
    cout << ans << "\n";
  }
  return 0;
}
