#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 100;
int n, m;
int a[maxn][maxn];
long long si[maxn], sj[maxn];
long long s, sr[maxn], sl[maxn], su[maxn], sd[maxn];
long long fsr[maxn], fsl[maxn], fsu[maxn], fsd[maxn];
int main() {
  cin >> n >> m;
  for (int i = 0, _n = (int)(n); i < _n; i++)
    for (int j = 0, _n = (int)(m); j < _n; j++) cin >> a[i][j];
  for (int i = 0, _n = (int)(n); i < _n; i++)
    for (int j = 0, _n = (int)(m); j < _n; j++)
      s += a[i][j], si[i] += a[i][j], sj[j] += a[i][j];
  for (int i = (int)(1), _n = (int)(n); i < _n; i++)
    su[i] = su[i - 1] + si[i - 1];
  for (int j = (int)(1), _n = (int)(m); j < _n; j++)
    sl[j] = sl[j - 1] + sj[j - 1];
  for (int i = (int)(n - 1), _x = (int)(0); i-- > _x;)
    sd[i] = sd[i + 1] + si[i + 1];
  for (int j = (int)(m - 1), _x = (int)(0); j-- > _x;)
    sr[j] = sr[j + 1] + sj[j + 1];
  for (int i = (int)(0), _n = (int)(n + 1); i < _n; i++)
    for (int k = 0, _n = (int)(i); k < _n; k++)
      fsu[i] += (2 * (i - k) - 1) * (2 * (i - k) - 1) * si[k];
  for (int j = (int)(0), _n = (int)(m + 1); j < _n; j++)
    for (int k = 0, _n = (int)(j); k < _n; k++)
      fsl[j] += (2 * (j - k) - 1) * (2 * (j - k) - 1) * sj[k];
  for (int i = (int)(n + 1), _x = (int)(0); i-- > _x;)
    for (int k = (int)(n), _x = (int)(i); k-- > _x;)
      fsd[i] += (2 * (k - i) + 1) * (2 * (k - i) + 1) * si[k];
  for (int j = (int)(m + 1), _x = (int)(0); j-- > _x;)
    for (int k = (int)(m), _x = (int)(j); k-- > _x;)
      fsr[j] += (2 * (k - j) + 1) * (2 * (k - j) + 1) * sj[k];
  long long ans = 1ll << 60;
  int bx, by;
  for (int i = 0, _n = (int)(n + 1); i < _n; i++)
    for (int j = 0, _n = (int)(m + 1); j < _n; j++) {
      long long cur = fsu[i] + fsd[i] + fsl[j] + fsr[j];
      if (cur < ans) ans = cur, bx = i, by = j;
    }
  cout << 4 * ans << endl;
  cout << bx << ' ' << by << endl;
  {
    int _;
    cin >> _;
  }
}
