#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int c[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x;
      scanf("%d", &x);
      c[i][j] = x;
    }
  }
  int cx[m], cy[n];
  memset(cx, 0, sizeof(cx));
  memset(cy, 0, sizeof(cy));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cx[j] += c[i][j];
      cy[i] += c[i][j];
    }
  }
  int minI = 0;
  long long minx = 1e18;
  for (int i = 0; i <= 4 * m; i += 4) {
    long long mx = 0;
    for (int x = 2; x <= 4 * m; x += 4) {
      long long lo = (long long)(i - x);
      long long co = (long long)cx[x / 4];
      mx += co * lo * lo;
    }
    if (mx < minx) {
      minI = i / 4;
      minx = mx;
    }
  }
  int minJ = 0;
  long long miny = 1e18;
  for (int j = 0; j <= 4 * n; j += 4) {
    long long my = 0;
    for (int y = 2; y <= 4 * n; y += 4) {
      long long lo = (long long)(j - y);
      long long co = (long long)cy[y / 4];
      my += co * lo * lo;
    }
    if (my < miny) {
      minJ = j / 4;
      miny = my;
    }
  }
  cout << minx + miny << endl;
  cout << minJ << " " << minI << endl;
}
