#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, n, m, a[10][10];
  cin >> t;
  while (t--) {
    cin >> n >> m;
    long long sum = 0;
    long long neg = 0;
    long long mi = INT_MAX;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] < 0) neg++, a[i][j] = -a[i][j];
        sum += a[i][j];
        mi = min(mi, a[i][j]);
      }
    }
    if (neg % 2) sum -= 2 * mi;
    cout << sum << "\n";
  }
  return 0;
}
