#include <bits/stdc++.h>
using namespace std;
long long r[1024][1024];
int main() {
  int n, m;
  cin >> n >> m;
  long long ssum = 0, a = 0, b = 0, c = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> r[i][j];
      long long int ii = i * 4 + 2, jj = j * 4 + 2;
      ssum += r[i][j];
      a += (r[i][j] * (ii * ii + jj * jj));
      b += (r[i][j] * ii);
      c += (r[i][j] * jj);
    }
  long long now, res = (1LL << 60), ri, rj;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) {
      long long ii = i * 4, jj = j * 4;
      now = (ssum * (ii * ii + jj * jj)) - 2LL * ii * b - 2LL * jj * c + a;
      if (now < res) {
        res = now, ri = i, rj = j;
      }
    }
  cout << res << endl;
  cout << ri << " " << rj << endl;
  return 0;
}
