#include <bits/stdc++.h>
using namespace std;
long long c[1005][1005], sumr[1005], sumc[1005], n, m;
long long check(long long x) {
  long long v = 0;
  for (long long i = 1; i <= m; i++) {
    if (i <= x)
      v += sumc[i] * (4 * (x - i) + 2) * (4 * (x - i) + 2);
    else
      v += sumc[i] * (4 * (i - x) - 2) * (4 * (i - x) - 2);
  }
  return v;
}
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      scanf("%lld", &c[i][j]);
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      sumr[i] += c[i][j];
    }
  }
  for (long long i = 1; i <= m; i++) {
    for (long long j = 1; j <= n; j++) {
      sumc[i] += c[j][i];
    }
  }
  long long nx = -1, ny = -1, ans = 5e18;
  for (long long i = 0; i <= n; i++) {
    long long l = 0, r = m, v = 0;
    for (long long j = 1; j <= n; j++) {
      if (j <= i)
        v += sumr[j] * (4 * (i - j) + 2) * (4 * (i - j) + 2);
      else
        v += sumr[j] * (4 * (j - i) - 2) * (4 * (j - i) - 2);
    }
    while (r >= l) {
      long long midl = l + (r - l) / 3, numl = check(midl);
      long long midr = r - (r - l) / 3, numr = check(midr);
      if (numl <= numr) {
        r = midr - 1;
        if (ans == numl + v) {
          if (nx > i)
            nx = i, ny = midl;
          else if (nx == i && ny > midl)
            ny = midl;
        }
        if (ans > numl + v) {
          ans = numl + v;
          nx = i;
          ny = midl;
        }
      } else {
        l = midl + 1;
        if (ans == numr + v) {
          if (nx > i)
            nx = i, ny = midr;
          else if (nx == i && ny > midr)
            ny = midr;
        }
        if (ans > numr + v) {
          ans = numr + v;
          nx = i;
          ny = midr;
        }
      }
    }
  }
  cout << ans << endl;
  cout << nx << " " << ny << endl;
}
