#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int MAX = 2010;
const long long mod = 1e9 + 7;
const int MAXLV = 16;
using namespace std;
int t;
int a[MAX][MAX];
int n, m;
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    int neg = 0;
    int menor = 0x3f3f3f3f;
    int tudo = 0;
    int zero = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        menor = min(menor, abs(a[i][j]));
        tudo += abs(a[i][j]);
        if (a[i][j] == 0) {
          ++zero;
        } else if (a[i][j] < 0) {
          ++neg;
        }
      }
    }
    if (zero) {
      cout << tudo << '\n';
    } else {
      if ((neg & 1)) {
        cout << tudo - 2 * menor << '\n';
      } else {
        cout << tudo << '\n';
      }
    }
  }
  return 0;
}
