#include <bits/stdc++.h>
using namespace std;
long long iinf = (1000 * 1000 * 1000 + 5) * (long long)(1000 * 1000 * 1000 + 5);
long long sx = 0, sy = 0, s1 = 0, s = 0, ans = iinf;
long long compute(long long i, long long j) {
  long long val = s * i * i + s * j * j + s1 + sx * i + sy * j;
  return val;
}
long long c[1005][1005];
int main() {
  std::ios::sync_with_stdio(false);
  int n, m, i, j, idx, idy;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> c[i][j];
      s += c[i][j];
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      sx += c[i][j] * -2 * (i * 4 + 2);
      sy += c[i][j] * -2 * (j * 4 + 2);
      s1 += c[i][j] * ((i * 4 + 2) * (i * 4 + 2) + (j * 4 + 2) * (j * 4 + 2));
    }
  }
  for (i = 0; i < n + 1; i++) {
    for (j = 0; j < m + 1; j++) {
      if (compute(4 * i, 4 * j) < ans) {
        ans = compute(4 * i, 4 * j);
        idx = i;
        idy = j;
      }
    }
  }
  cout << ans << endl;
  cout << idx << " " << idy << endl;
}
