#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long arr[n][m];
    long long sum = 0;
    long long mini = 1e4;
    long long ans = 0;
    long long zero = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        cin >> arr[i][j];
        if (arr[i][j] < 0) {
          sum++;
        }
        if (arr[i][j] == 0) {
          zero++;
        }
        mini = min(abs(arr[i][j]), mini);
        ans += abs(arr[i][j]);
      }
    }
    if (sum % 2 == 0 || zero >= 1) {
      cout << ans << "\n";
    } else {
      long long val = ans - 2 * mini;
      cout << val << "\n";
    }
  }
}
