#include <iostream>
#include <vector>

using namespace std;

// Function to find the maximum sum submatrix and its coordinates
void findMaxSubmatrix(int r, int c, vector<vector<int>>& matrix) {


    int maxSum = matrix[0][0];
    int topLeftRow = 0, topLeftCol = 0;
    int bottomRightRow = 0, bottomRightCol = 0;

    // Iterate over all possible top-left corners
    for (int topRow = 0; topRow < r; topRow++) {
        for (int leftCol = 0; leftCol < c; leftCol++) {
            // Iterate over all possible bottom-right corners
            for (int bottomRow = topRow; bottomRow < r; bottomRow++) {
                for (int rightCol = leftCol; rightCol < c; rightCol++) {
                    // Calculate sum of submatrix
                    int currentSum = 0;
                    for (int i = topRow; i <= bottomRow; i++) {
                        for (int j = leftCol; j <= rightCol; j++) {
                            currentSum += matrix[i][j];
                        }
                    }
                    // Update maxSum and coordinates if found a larger sum
                    if (currentSum > maxSum) {
                        maxSum = currentSum;
                        topLeftRow = topRow;
                        topLeftCol = leftCol;
                        bottomRightRow = bottomRow;
                        bottomRightCol = rightCol;
                    }
                }
            }
        }
    }

    // Output the maximum sum and submatrix coordinates
    cout << maxSum << endl;
    cout << "(" << topLeftRow << ", " << topLeftCol << ") to (" << bottomRightRow << ", " << bottomRightCol << ")" << endl;
}

int main() {
    int r, c;
    cin >> r >> c;
    if (r <= 0 || c <= 0 || r > 5 || c > 5) {
        cout << "Invalid Input" << endl;
        return 1;
    }
    // Read matrix elements
    vector<vector<int>> matrix(r, vector<int>(c));
    for (int i = 0; i < r; i++) {
        for (int j = 0; j < c; j++) {
            cin >> matrix[i][j];
        }
    }

    // Find and print the maximum sum submatrix and its coordinates
    findMaxSubmatrix(r, c, matrix);

    return 0;
}
