#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> ss;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int arr[n][m];
    long long int sm = 0, mn = LLONG_MAX;
    long long int c = 0;
    bool flag = 0;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cin >> arr[i][j];
        sm += abs(arr[i][j]);
        mn = min(abs(arr[i][j]), mn);
        if (arr[i][j] == 0) {
          flag = 1;
        }
        if (arr[i][j] < 0) {
          c++;
        }
      }
    }
    if (c % 2 == 0 || flag == 1) {
      cout << sm;
    } else {
      cout << sm - 2 * mn;
    }
    cout << '\n';
  }
}
