#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long M = 3e5 + 7, N = 500;
long long fact[1001];
long long power(long long x, long long y) {
  long long res = 1;
  x = x % 1000000007;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
long long ad(long long a, long long b) {
  return ((a % 1000000007 + b % 1000000007) % 1000000007);
}
long long sub(long long a, long long b) {
  return ((a % 1000000007 - b % 1000000007 + 1000000007) % 1000000007);
}
long long mul(long long a, long long b) {
  return (((a % 1000000007) * (b % 1000000007)) % 1000000007);
}
long long divi(long long a, long long b) {
  return (mul(a, power(b, 1000000007 - 2)) % 1000000007);
}
long long ncr(long long n, long long r) {
  if (r > n) return 0;
  return divi(fact[n], mul(fact[n - r], fact[r]));
}
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long po(long long n, long long exp) {
  if (exp == 0) return 1 % 1000000007;
  long long n2 = po(n, (exp >> 1)) % 1000000007;
  return (exp & 1) == 0 ? (n2 * n2) % 1000000007 : (n * n2 * n2) % 1000000007;
}
vector<long long> primeNum;
bool prime[10000000];
unordered_set<long long> s;
void Sieve() {
  long long N = 10000000;
  for (long long i = 4; i < N; i += 2) prime[i] = true;
  primeNum.push_back(2);
  s.insert(2);
  for (long long i = 3; i < N; i++) {
    if (!prime[i]) {
      s.insert(i);
      primeNum.push_back(i);
      for (long long j = i * i; j < N; j += 2 * i) {
        prime[j] = true;
      }
    }
  }
  return;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(n, vector<long long>(m));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cin >> v[i][j];
  }
  long long sum1 = 0, count = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (v[i][j] < 0) count++;
    }
  }
  if (count % 2 == 0) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) sum1 += abs(v[i][j]);
    }
  } else {
    long long min1 = 101;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        v[i][j] = abs(v[i][j]);
        min1 = min(min1, v[i][j]);
      }
    }
    for (long long i = 0; i < n; i++) {
      bool flag = false;
      for (long long j = 0; j < m; j++) {
        if (v[i][j] == min1) {
          v[i][j] = -v[i][j];
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) sum1 += v[i][j];
    }
  }
  cout << sum1 << endl;
}
int32_t main() {
  c_p_c();
  long long x;
  cin >> x;
  while (x--) solve();
  return 0;
}
