#include <bits/stdc++.h>
using namespace std;
long long ans = 1000000000000000000ll;
struct point {
  long long c, x, y;
};
int np;
long long nx, ny;
point p[1111111];
int m, n;
long long dis(point u, point v) {
  return (u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y);
}
void update(int x, int y) {
  point u;
  u.x = x;
  u.y = y;
  long long res = 0;
  for (int i = 1; i <= np; i++) res += p[i].c * dis(p[i], u);
  if ((res < ans) || (ans == -1))
    ans = res, nx = x, ny = y;
  else if (res == ans) {
    if ((x < nx) || ((x == nx) && (y < ny))) nx = x, ny = y;
  }
}
int main() {
  cin >> m >> n;
  np = 0;
  long long value, tong, x, y;
  double tonx, tony;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      scanf("%I64d", &value);
      np++;
      p[np].c = value;
      p[np].x = (i - 1) * 4 + 2;
      p[np].y = (j - 1) * 4 + 2;
    }
  tong = 0;
  for (int i = 1; i <= np; i++) tong += p[i].c;
  if (tong == 0) {
    cout << 0 << endl;
    cout << 0 << " " << 0;
    return 0;
  }
  tonx = 0;
  for (int i = 1; i <= np; i++) tonx += p[i].c * p[i].x;
  tony = 0;
  for (int i = 1; i <= np; i++) tony += p[i].c * p[i].y;
  x = trunc(tonx / tong);
  y = trunc(tony / tong);
  y = y / 4 * 4;
  x = x / 4 * 4;
  nx = -1;
  ny = -1;
  ans = -1;
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++) update(x + i * 4, y + j * 4);
  cout << ans << endl;
  cout << nx / 4 << " " << ny / 4 << endl;
  return 0;
}
