#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
inline void read(register long long &ret) {
  ret = 0;
  register char c = getchar();
  register bool pd = false;
  while (!isdigit(c)) {
    pd |= c == '-';
    c = getchar();
  }
  while (isdigit(c)) {
    ret = (ret << 1) + (ret << 3) + (c & 15);
    c = getchar();
  }
  ret = pd ? -ret : ret;
  return;
}
long long t, n, m, a[2001][2001], ans;
signed main() {
  read(t);
  while (t--) {
    read(n);
    read(m);
    register long long ret = 0;
    register long long tmp = 1e18;
    ans = 0;
    for (register int i = 1; i <= n; i++) {
      for (register int j = 1; j <= m; j++) {
        read(a[i][j]);
        if (a[i][j] < 0) ret++;
        tmp = min(tmp, abs(a[i][j]));
        ans += abs(a[i][j]);
      }
    }
    if (ret & 1)
      printf("%lld\n", ans - (tmp << 1));
    else
      printf("%lld\n", ans);
  }
  exit(0);
}
