#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, m, i, j, zero = 0, neg = 0, tot = 0, val = INT_MIN,
                              val2 = INT_MAX;
    cin >> n >> m;
    long long int b[n][m];
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        cin >> b[i][j];
        if (b[i][j] < 0) {
          neg++;
          if (neg == 1)
            val = b[i][j];
          else if (val < b[i][j])
            val = b[i][j];
        } else if (b[i][j] == 0)
          zero++;
        else
          val2 = min(val2, b[i][j]);
        tot += abs(b[i][j]);
      }
    }
    if (neg % 2 == 0 || zero != 0)
      cout << tot << endl;
    else {
      cout << tot + 2 * max(val, -val2) << endl;
    }
  }
}
