#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::vector;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int m;
    int n;
    cin >> n >> m;
    vector<vector<int>> rec(n);
    bool is_zero = false;
    bool is_even = true;
    int max = -101;
    int min = 101;
    int sum = 0;
    for (vector<int> &vec : rec) {
      vec.resize(m);
      for (int &number : vec) {
        cin >> number;
        if (number < 0) {
          sum -= number;
          if (max < number) {
            max = number;
          }
          if (is_even) {
            is_even = false;
          } else {
            is_even = true;
          }
        } else if (number == 0) {
          is_zero = true;
        } else {
          sum += number;
          if (min > number) {
            min = number;
          }
        }
      }
    }
    if (is_even || is_zero) {
      cout << sum << "\n";
      continue;
    }
    if (-max > min)
      cout << sum - 2 * min;
    else
      cout << sum + 2 * max;
    cout << "\n";
  }
}
