#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void boostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
}
bool isPrime(int x) {
  if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
  for (int i = 5; i * i <= x; i += 6)
    if (x % i == 0 || x % (i + 2) == 0) return 0;
  return 1;
}
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
template <typename T>
inline T getint() {
  T val = 0;
  char c;
  bool neg = false;
  while ((c = getchar()) && !(c >= '0' && c <= '9')) {
    neg |= c == '-';
  }
  do {
    val = (val * 10) + c - '0';
  } while ((c = getchar()) && (c >= '0' && c <= '9'));
  return val * (neg ? -1 : 1);
}
long long Mod = 998244353;
long long inf = 1e18 + 5;
int32_t main() {
  boostIO();
  long long T;
  cin >> T;
  while (T--) {
    long long n, m;
    cin >> n >> m;
    vector<vector<long long>> A(n, vector<long long>(m));
    long long sum = 0;
    long long neg = 0;
    long long MAMA = inf;
    for (long long i = 0; i < (n); ++i) {
      for (long long j = 0; j < (m); ++j) {
        cin >> A[i][j];
        sum += abs(A[i][j]);
        MAMA = min(MAMA, abs(A[i][j]));
        if (A[i][j] < 0) neg++;
      }
    }
    cerr << "ans = ";
    if (neg % 2 == 0)
      cout << sum << '\n';
    else
      cout << sum - MAMA * 2 << '\n';
  }
}
