3 Rules
If we have a zero anywhere we can use it to flip all negatives into positives.\n2. If we have even number of negatives, we can turn all negatives into positives
1. If we have a zero anywhere we can use it to flip all negatives into positives.\n2. If we have even number of negatives, we can turn all negatives into positives.\n3. Otherwise, we turn the smallest absolute value into a negative, and everything else - into positives.\n\n**C++**\n```cpp\nlong long maxMatrixSum(vector<vector<int>>& m) {\n    long long sum = 0, zeros = 0, negs = 0, min_abs = INT_MAX;\n    for (int i = 0; i < m.size(); ++i)\n        for (int j = 0; j < m[i].size(); ++j) {\n            sum += abs(m[i][j]);\n            zeros += m[i][j] == 0;\n            negs += m[i][j] < 0;\n            min_abs = min(min_abs, (long long)abs(m[i][j]));\n        }\n    return sum - (zeros || negs % 2 == 0 ? 0 : 2 * min_abs);\n}\n```\n
[]