#include <bits/stdc++.h>
using namespace std;
const int X = 100000 + 5;
long long C[1005][1005];
long long n, m;
long long iis, ii, jjs, jj, cc;
void calc() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cc += C[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ii += C[i][j] * (i * 4 + 2);
      iis += (i * 4 + 2) * (i * 4 + 2) * C[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      jj += C[i][j] * (j * 4 + 2);
      jjs += (j * 4 + 2) * (j * 4 + 2) * C[i][j];
    }
  }
}
long long dist(long long x, long long y) {
  x *= 4;
  y *= 4;
  long long s = iis + x * x * cc - 2 * x * ii + jjs + y * y * cc - 2 * y * jj;
  return s;
}
long long foo(long long x, long long& z) {
  long long lo = 0, hi = m, mm = LLONG_MAX;
  while (lo + 2 < hi) {
    long long ml = lo + (hi - lo) / 3, mr = hi - (hi - lo) / 3;
    long long l = dist(x, ml), r = dist(x, mr);
    if (l <= r)
      hi = mr;
    else
      lo = ml;
  }
  for (int i = 0; i <= 2; i++) {
    long long cc = dist(x, lo + i);
    if (cc < mm) {
      mm = cc;
      z = lo + i;
    }
  }
  return mm;
}
void MAIN() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> C[i][j];
    }
  }
  calc();
  long long mm = LLONG_MAX, xx = -1, yy = -1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      long long z = dist(i, j);
      if (z < mm) {
        mm = z;
        xx = i;
        yy = j;
      }
    }
  }
  cout << mm << '\n' << xx << " " << yy;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(12);
  MAIN();
  return 0;
}
