#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn = 100001, inf = 2147483647;
const long long mod = 1 ? 998244353 : 1000000007, linf = 9223372036854775807;
const double pi = acos(-1);
inline long long mi(long long a, long long b, long long mm = mod) {
  a %= mm;
  long long u = 1;
  while (b) {
    if (b & 1) u = u * a % mm;
    a = a * a % mm, b >>= 1;
  }
  return u;
}
inline long long gcd(long long a, long long b) {
  long long c = a % b;
  while (c) a = b, b = c, c = a % b;
  return b;
}
inline void mem(int* a, int p = 0, int len = maxn) {
  for (int i = 0; i < len; i++) a[i] = p;
}
struct p {
} e;
int t, n, a[maxn], b[maxn], x, m;
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    x = 0;
    b[0] = 10000, b[1] = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        cin >> a[0], x += abs(a[0]), b[0] = min(b[0], abs(a[0])),
                                     b[1] += a[0] < 0;
    cout << x - 2 * b[0] * (b[1] % 2) << endl;
  }
}
