#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, sum = 0;
    cin >> n >> m;
    int a[n][m], ct = 0, f = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] < 0) ct++;
        if (a[i][j] == 0) f++;
      }
    if (ct % 2 == 0 || f) {
      sum = 0;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) sum += abs(a[i][j]);
      cout << sum << endl;
    } else {
      int mn = 1000;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
          sum += abs(a[i][j]);
          mn = min(mn, abs(a[i][j]));
        }
      cout << sum - 2 * mn << endl;
    }
  }
  return 0;
}
