#include <bits/stdc++.h>
#pragma GCC optimize(2)
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e2 + 10;
int n, T, m;
int a[N][N];
int main() {
  T = read();
  while (T--) {
    n = read(), m = read();
    int temp = 0;
    int zero = 0;
    int sum = 0;
    int minn = INF;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        a[i][j] = read();
        if (a[i][j] < 0) temp++;
        if (a[i][j] == 0) zero++;
        sum += abs(a[i][j]);
        minn = min(minn, abs(a[i][j]));
      }
    }
    if (temp % 2 == 0) {
      cout << sum << endl;
    } else if (temp % 2 == 1 && zero) {
      cout << sum << endl;
    } else
      cout << sum - 2 * minn << endl;
  }
  return 0;
}
