#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int temp;
  long long int sum = 0;
  long long int count_neg = 0;
  long long int min_pos = INT_MAX;
  long long int max_neg = INT_MIN;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> temp;
      sum += abs(temp);
      if (temp <= 0) {
        max_neg = max(max_neg, temp);
        count_neg++;
      } else {
        min_pos = min(min_pos, temp);
      }
    }
  }
  if (count_neg & 1) sum += max(2 * max_neg, -2 * min_pos);
  cout << sum << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int TC;
  cin >> TC;
  while (TC--) {
    solve();
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
