#include <bits/stdc++.h>
using namespace std;
int n, m;
long long arr[1005][1005], srow[1005], scol[1005];
void doit() {
  long long minval = -1, currval, minix, minjx, ret, dist;
  cin >> n >> m;
  memset(srow, 0, sizeof(srow));
  memset(scol, 0, sizeof(scol));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      srow[i] += arr[i][j];
      scol[j] += arr[i][j];
    }
  for (int i = 0; i < n + 1; i++) {
    currval = 0;
    for (int j = 0; j < i; j++) {
      dist = (i - j - 1) * 4 + 2;
      currval += (srow[j] * dist * dist);
    }
    for (int j = i; j < n + 1; j++) {
      dist = (j - i) * 4 + 2;
      currval += (srow[j] * dist * dist);
    }
    if (minval == -1 || minval > currval) {
      minval = currval;
      minix = i;
    }
  }
  ret = minval;
  minval = -1;
  for (int i = 0; i < m + 1; i++) {
    currval = 0;
    for (int j = 0; j < i; j++) {
      dist = (i - j - 1) * 4 + 2;
      currval += (scol[j] * dist * dist);
    }
    for (int j = i; j < m + 1; j++) {
      dist = (j - i) * 4 + 2;
      currval += (scol[j] * dist * dist);
    }
    if (minval == -1 || minval > currval) {
      minval = currval;
      minjx = i;
    }
  }
  cout << ret + minval << endl;
  cout << minix << " " << minjx << endl;
  return;
}
int main() {
  doit();
  return 0;
}
