#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int mod2 = 4294967296;
vector<int> ar[100001];
vector<int> order;
vector<int> scc;
vector<int> tr[100001];
int visited[100001];
int color[100001];
int dist[100001];
int level[100001];
int in[100001];
int out[100001];
set<int> articulation_point;
vector<int> prime;
long long int maxd, maxn;
int timer, bachhe;
bool visi[1001][1001];
int grid[1001][1001];
int dis[1001][1001];
int n, m, connected;
char c[31][31];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
long long int msb__(long long int n) {
  long long int msb = 0;
  if (n == 0) {
    return 0;
  } else {
    while (n) {
      n /= 2;
      msb++;
    }
  }
  return msb;
}
int tests() {
  int n, m;
  cin >> n >> m;
  int a[n][m], sum = 0, mini = INT_MAX, count = 0;
  bool zero = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] < 0) {
        count++;
      } else if (a[i][j] == 0) {
        zero = true;
      }
      mini = min(mini, abs(a[i][j]));
      sum += abs(a[i][j]);
    }
  }
  if (zero == true || count % 2 == 0) {
    cout << sum << "\n";
  } else {
    sum -= 2 * mini;
    cout << sum << "\n";
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    tests();
  }
  return 0;
}
