#include <bits/stdc++.h>
using namespace std;
void dfs(vector<vector<long long>>& g, long long& p, long long& u,
         vector<long long>& par, vector<long long>& pre, long long& prev,
         vector<long long>& w) {
  par[u] = p;
  long long temp = prev % 4294967296 +
                   ((w[u] % 4294967296) * (w[u] % 4294967296)) % 4294967296;
  pre[u] = temp % 4294967296;
  for (auto v : g[u]) {
    if (v == p) continue;
    dfs(g, u, v, par, pre, pre[u], w);
  }
}
void dfs(long long u, long long p, vector<vector<long long>>& memo,
         vector<long long>& lev, long long log, vector<vector<long long>> g,
         vector<long long>& par, vector<long long>& pre, long long prew,
         vector<long long> w) {
  long long temp = prew % 4294967296 +
                   ((w[u] % 4294967296) * (w[u] % 4294967296)) % 4294967296;
  pre[u] = temp % 4294967296;
  par[u] = p;
  memo[u][0] = p;
  for (long long i = 1; i <= log; i++) memo[u][i] = memo[memo[u][i - 1]][i - 1];
  for (long long v : g[u]) {
    if (v != p) {
      lev[v] = lev[u] + 1;
      dfs(v, u, memo, lev, log, g, par, pre, pre[u], w);
    }
  }
}
long long lca(long long u, long long v, long long log, vector<long long> lev,
              vector<vector<long long>> memo) {
  if (lev[u] < lev[v]) swap(u, v);
  for (long long i = log; i >= 0; i--)
    if ((lev[u] - pow(2, i)) >= lev[v]) u = memo[u][i];
  if (u == v) return u;
  for (long long i = log; i >= 0; i--) {
    if (memo[u][i] != memo[v][i]) {
      u = memo[u][i];
      v = memo[v][i];
    }
  }
  return memo[u][0];
}
class Node {
 public:
  int val;
  int count;
  Node* left;
  Node* right;
  Node(int num1, int num2) {
    this->val = num1;
    this->count = num2;
    this->left = this->right = NULL;
  }
};
long long addNode(Node*& root, long long value, long long countSmaller) {
  if (root == NULL) {
    root = new Node(value, 1);
    return countSmaller;
  }
  if (root->val < value) {
    root->count++;
    return addNode(root->right, value, countSmaller);
  } else {
    return root->count + addNode(root->left, value, countSmaller + 1);
  }
}
struct num {
  long long pos;
  long long val;
};
void merge(vector<num>& a, vector<long long>& ct, long long l, long long r,
           long long n) {
  if (l >= r) return;
  long long s1 = l, e1 = (l + r) / 2;
  long long s2 = (l + r) / 2 + 1, e2 = r;
  long long k = 0, i = s1, j = s2;
  vector<num> c(n);
  while (i <= e1 && j <= e2) {
    if (a[i].val >= a[j].val) {
      c[k].val = a[i].val;
      c[k].pos = a[i].pos;
      k++;
      i++;
    } else if (a[i].val < a[j].val) {
      c[k].val = a[j].val;
      c[k].pos = a[j].pos;
      ct[a[i].pos] += (e2 - j + 1);
      k++;
      j++;
    }
  }
  while (i <= e1) {
    c[k].val = a[i].val;
    c[k].pos = a[i].pos;
    k++;
    i++;
  }
  while (j <= e2) {
    c[k].val = a[j].val;
    c[k].pos = a[j].pos;
    k++;
    j++;
  }
  for (long long i = l; i <= r; i++) a[i] = c[i - l];
  return;
}
void mergesort(vector<num>& a, vector<long long>& ct, long long l, long long r,
               long long n) {
  if (l >= r) return;
  cout << l << " " << r << "\n";
  mergesort(a, ct, l, (l + r) / 2, n);
  mergesort(a, ct, (l + r) / 2 + 1, r, n);
  merge(a, ct, l, r, n);
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long ma = LLONG_MAX, s = 0, c = 0;
    vector<vector<long long>> a(n, vector<long long>(m));
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        cin >> a[i][j];
        ma = min(ma, abs(a[i][j]));
        s += abs(a[i][j]);
        if (a[i][j] < 1) c++;
      }
    }
    if (c % 2 == 0)
      cout << s << "\n";
    else
      cout << (s - 2 * ma) << "\n";
  }
  return 0;
}
