#include <bits/stdc++.h>
using namespace std;
const int N = 1009;
int a[N][N], i, j, n, m, l, r, ansi, ansj;
long long d, si[N], sj[N], reti, retj;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      si[i] += a[i][j];
      sj[j] += a[i][j];
    }
  }
  reti = retj = (1 << 30) * 1ll * (1 << 30);
  for (i = 0; i <= n; i++) {
    d = 0;
    for (j = 0; j < n; j++) {
      if (j < i)
        l = (i - j - 1) * 4 + 2;
      else
        l = (j - i) * 4 + 2;
      d += si[j] * ((l) * (l));
    }
    if (d < reti) {
      reti = d;
      ansi = i;
    }
  }
  for (i = 0; i <= m; i++) {
    d = 0;
    for (j = 0; j < m; j++) {
      if (j < i)
        l = (i - j - 1) * 4 + 2;
      else
        l = (j - i) * 4 + 2;
      d += sj[j] * ((l) * (l));
    }
    if (d < retj) {
      retj = d;
      ansj = i;
    }
  }
  cout << reti + retj << "\n" << ansi << " " << ansj;
}
