#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long maxN = 50005;
long long ceill(long long a, long long b) { return a / b + bool(a % b); }
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return res;
}
void bin(unsigned n, string &str) {
  str = "";
  if (n > 1) bin(n >> 1, str);
  str += to_string(n & 1);
}
bool isPrime(long long n) {
  if (n <= 1)
    return false;
  else if (n <= 3)
    return true;
  else if (n % 2 == 0 || n % 3 == 0)
    return false;
  for (long long i = 5; i * i <= n; i = i + 6) {
    if (n % i == 0 || n % (i + 2) == 0) return false;
  }
  return true;
}
vector<long long> primes;
void SieveOfEratosthenes() {
  bool prime[maxN];
  primes.clear();
  memset(prime, true, sizeof(prime));
  for (long long i = 2; i * i < maxN; i++)
    if (prime[i] == true)
      for (long long j = i * i; j < maxN; j += i) prime[j] = false;
  for (long long i = 2; i < maxN; i++)
    if (prime[i]) primes.push_back(i);
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long cnt = 0, tmp = 0, sum = 0, minn = 1e18;
  for (long long i = 0; i < n * m; i++) {
    cin >> tmp;
    if (tmp < 0) cnt++;
    minn = min(minn, abs(tmp));
    sum += abs(tmp);
  }
  if (minn > 0 && cnt % 2 == 1)
    cout << sum - 2 * minn << '\n';
  else
    cout << sum << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tc = 1;
  cin >> tc;
  for (long long t = 1; t <= tc; t++) {
    solve();
  }
}
