#include <bits/stdc++.h>
using namespace std;
const long long M = 998244353LL;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n + 1, vector<int>(m + 1));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> a[i][j];
    int ans = 0, cnt = 0, mn = 2e9;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        ans += abs(a[i][j]);
        mn = min(mn, abs(a[i][j]));
        if (a[i][j] < 0) cnt++;
      }
    }
    if (cnt % 2 == 0)
      cout << ans << endl;
    else
      cout << ans - 2 * mn << endl;
  }
}
