#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, i, j, s, r, c, x, y, prev_sum, val, k, sum, ans;
  cin >> n >> m;
  long long A[n][m], B[n + 1][m + 1];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> A[i][j];
  long long R[n + 1], C[m + 1], UR[n + 1], UC[m + 1];
  R[0] = 0;
  UR[n] = 0;
  C[0] = 0;
  UC[m] = 0;
  for (i = 0; i < n; i++) {
    s = 0;
    for (j = 0; j < m; j++) s += A[i][j];
    R[i + 1] = R[i] + s;
  }
  for (i = 1; i <= n; i++) R[i] = R[i - 1] + R[i];
  for (i = n - 1; i >= 0; i--) {
    s = 0;
    for (j = 0; j < m; j++) s += A[i][j];
    UR[i] = UR[i + 1] + s;
  }
  for (i = n - 1; i >= 0; i--) UR[i] = UR[i + 1] + UR[i];
  for (i = 0; i < m; i++) {
    s = 0;
    for (j = 0; j < n; j++) s += A[j][i];
    C[i + 1] = C[i] + s;
  }
  for (i = 1; i <= m; i++) C[i] += C[i - 1];
  for (i = m - 1; i >= 0; i--) {
    s = 0;
    for (j = 0; j < n; j++) s += A[j][i];
    UC[i] = UC[i + 1] + s;
  }
  for (i = m - 1; i >= 0; i--) UC[i] += UC[i + 1];
  s = 0;
  for (i = 0; i < n; i++) {
    r = i * 4 + 2;
    for (j = 0; j < m; j++) {
      c = j * 4 + 2;
      s += A[i][j] * (c * c + r * r);
    }
  }
  B[0][0] = s;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= m; j++) {
      if (i == 0 && j == 0) continue;
      if (j == 0)
        B[i][0] = B[i - 1][0] - UR[i] * 32 + R[i - 1] * 32;
      else
        B[i][j] = B[i][j - 1] - UC[j] * 32 + C[j - 1] * 32;
    }
  }
  ans = B[0][0];
  x = 0;
  y = 0;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= m; j++) {
      if (ans > B[i][j]) {
        ans = B[i][j];
        x = i;
        y = j;
      }
    }
  }
  cout << ans << "\n";
  cout << x << " " << y << "\n";
}
