#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
bool compare(const pair<int, int>& i, const pair<int, int>& j) {
  return i.second < j.second;
}
long long modexp(long long x, long long n) {
  long long r = 1ll;
  while (n) {
    if (n & 1) r = (r * x) % int(1e9 + 7);
    x = (x * x) % int(1e9 + 7);
    n >>= 1;
  }
  return r;
}
void solve() {
  int n, m;
  cin >> n >> m;
  int A[n + 5][m + 5];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> A[i][j];
  }
  int mini = INT_MAX, sum = 0, ncnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (A[i][j] < 0) ncnt++;
      mini = min(mini, abs(A[i][j]));
      sum = sum + abs(A[i][j]);
    }
  }
  if (!(ncnt % 2))
    cout << sum << "\n";
  else
    cout << sum - 2 * mini << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
