#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 4e18;
const int inf = 2e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long row[1005], col[1005], x[1005], y[1005];
long long ans = INF;
int c[1005][1005];
int main(void) {
  int n, m, i, j, ii, jj;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) {
      scanf("%d", &c[i][j]);
      row[i] += c[i][j];
      col[j] += c[i][j];
    }
  for (i = 1; i <= n; ++i)
    for (ii = 0; ii <= n; ++ii) {
      long long dis = (ii < i ? (i - ii - 1) * 4 + 2 : (ii - i) * 4 + 2);
      dis *= dis;
      x[ii] += dis * row[i];
    }
  for (j = 1; j <= m; ++j)
    for (jj = 0; jj <= m; ++jj) {
      long long dis = (jj < j ? (j - jj - 1) * 4 + 2 : (jj - j) * 4 + 2);
      dis *= dis;
      y[jj] += dis * col[j];
    }
  int li, lj;
  for (i = 0; i <= n; ++i)
    for (j = 0; j <= m; ++j) {
      long long cur = x[i] + y[j];
      if (cur < ans) {
        ans = cur;
        li = i;
        lj = j;
      }
    }
  cout << ans << endl;
  printf("%d %d\n", li, lj);
  return 0;
}
