#include <bits/stdc++.h>
using namespace std;
void online(void) {}
const long long N = 1299721;
vector<long long> prime(N, 1);
vector<long long> c;
void sieve(int N) {
  prime[0] = 0;
  prime[1] = 0;
  for (long long i = 2; i <= sqrt(N); i++) {
    if (prime[i] == 1) {
      for (long long j = (i * i); j <= N; j += i) prime[j] = 0;
    }
  }
}
int main() {
  online();
  int t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long a[n][m];
    long long sum = 0, mn = INT_MAX, cnt = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] < 0) {
          cnt++;
        }
        mn = min(mn, abs(a[i][j]));
        sum += abs(a[i][j]);
      }
    }
    if (cnt % 2 == 0)
      cout << sum << endl;
    else
      cout << sum - 2 * mn << endl;
  }
}
