#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 * 1000 + 10;
const long long INF = 2000000000000000000;
int n, m, c[maxn][maxn], x, y;
long long cyl, cyr, cl, cr, cxu, cxd, cu, cd, px[maxn], py[maxn], sx, sy,
    mn = INF;
pair<int, int> ans;
inline void moved() {
  sx += cu * 16 + cxu * 8 + cd * 16 - cxd * 8;
  cxu += cu * 4 + px[x] * 2;
  cxd -= cd * 4 + px[x + 1] * 2;
  cu += px[x];
  cd -= px[x + 1];
}
inline void movel() {
  sy += (cr + py[y]) * 16 + (cyr + py[y] * 2) * 8 + cl * 16 - cyl * 8;
  cyr += cr * 4 + py[y] * 6;
  if (y > 1) cyl -= cl * 4 + py[y - 2] * 2;
  cr += py[y];
  if (y > 1) cl -= py[y - 2];
}
inline void mover() {
  sy += cl * 16 + cyl * 8 + cr * 16 - cyr * 8;
  cyl += cl * 4;
  if (y > 0) {
    sy += py[y - 1] * 32;
    cyl += py[y - 1] * 6;
    cl += py[y - 1];
  }
  cyr -= cr * 4 + py[y + 1] * 2;
  cr -= py[y + 1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
      px[i] += c[i][j];
      py[j] += c[i][j];
      sx += (long long)c[i][j] * (4 * i + 2) * (4 * i + 2);
      sy += (long long)c[i][j] * (4 * j + 2) * (4 * j + 2);
      if (i > 0) {
        cd += c[i][j];
        cxd += (long long)c[i][j] * (4 * i + 2);
      }
      if (j > 0) {
        cr += c[i][j];
        cyr += (long long)c[i][j] * (4 * j + 2);
      }
    }
  }
  for (x = 0; x <= n; x++) {
    if (x & 1) {
      for (y = m; y >= 0; y--) {
        if (sx + sy < mn || (sx + sy == mn && make_pair(x, y) < ans)) {
          mn = sx + sy;
          ans = make_pair(x, y);
        }
        if (y > 0) movel();
      }
    } else {
      for (y = 0; y <= m; y++) {
        if (sx + sy < mn || (sx + sy == mn && make_pair(x, y) < ans)) {
          mn = sx + sy;
          ans = make_pair(x, y);
        }
        if (y < m) mover();
      }
    }
    if (x < n) moved();
  }
  cout << mn << endl << ans.first << " " << ans.second;
  return 0;
}
