#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-12, PI = 2 * acos(0.0);
void came(int x) { cout << "Came " << x << endl; }
int n, m, i, j, k, posr, posc;
long long sum[1005][1005], rowSumTemp[1005], c[1005][1005], weightColLeft[1005],
    weightColRight[1005], weightRowUp[1005], weightRowDown[1005], ans, tempAns;
long long ColSum(int col) {
  if (col == 0) return sum[n - 1][0];
  return sum[n - 1][col] - sum[n - 1][col - 1];
}
long long RowSum(int row) {
  if (row == 0) return sum[0][m - 1];
  return sum[row][m - 1] - sum[row - 1][m - 1];
}
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      int tempppp;
      scanf("%d", &tempppp);
      c[i][j] = tempppp;
    }
  sum[0][0] = c[0][0];
  for (j = 1; j < m; j++) sum[0][j] = sum[0][j - 1] + c[0][j];
  for (i = 1; i < n; i++) {
    rowSumTemp[0] = c[i][0];
    sum[i][0] = sum[i - 1][0] + c[i][0];
    for (j = 1; j < m; j++) {
      rowSumTemp[j] = rowSumTemp[j - 1] + c[i][j];
      sum[i][j] = sum[i - 1][j] + rowSumTemp[j];
    }
  }
  for (i = 0; i < m; i++) {
    weightColLeft[i] = 0;
    for (j = i, k = 2; j >= 0; j--, k += 4)
      weightColLeft[i] += ColSum(j) * k * k;
  }
  for (i = 0; i < m; i++) {
    weightColRight[i] = 0;
    for (j = i, k = 2; j < m; j++, k += 4)
      weightColRight[i] += ColSum(j) * k * k;
  }
  for (i = 0; i < n; i++) {
    weightRowUp[i] = 0;
    for (j = i, k = 2; j >= 0; j--, k += 4) weightRowUp[i] += RowSum(j) * k * k;
  }
  for (i = 0; i < n; i++) {
    weightRowDown[i] = 0;
    for (j = i, k = 2; j < n; j++, k += 4)
      weightRowDown[i] += RowSum(j) * k * k;
  }
  ans = weightColRight[0] + weightRowDown[0];
  posr = 0;
  posc = 0;
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++) {
      tempAns =
          (j > 0 ? weightColLeft[j - 1] : 0) + (j < m ? weightColRight[j] : 0) +
          (i > 0 ? weightRowUp[i - 1] : 0) + (i < n ? weightRowDown[i] : 0);
      if (tempAns < ans) {
        ans = tempAns;
        posr = i;
        posc = j;
      }
    }
  cout << ans << endl;
  cout << posr << " " << posc << endl;
  return 0;
}
