#include <bits/stdc++.h>
using namespace std;
long long b[1 << 10][1 << 10];
long long c[1 << 10], r[1 << 10];
int n, m;
int main() {
  int i, j;
  scanf("%d %d", &n, &m);
  memset(c, 0, sizeof(c));
  memset(r, 0, sizeof(r));
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      scanf("%I64d", &b[i][j]);
      r[i] += b[i][j];
      c[j] += b[i][j];
    }
  }
  long long bestr, bestc, best;
  bestr = bestc = best = (1LL << 60);
  int row, col;
  for (i = 0; i <= n; ++i) {
    long long cur = 0;
    for (j = 0; j < n; ++j) {
      long long dist = 0;
      if (i <= j) {
        dist = 4 * (j - i) + 2;
      } else {
        dist = 4 * (i - j) - 2;
      }
      dist *= dist;
      cur += dist * r[j];
    }
    if (cur < bestr) {
      bestr = cur;
      row = i;
    }
  }
  for (i = 0; i <= m; ++i) {
    long long cur = 0;
    for (j = 0; j < m; ++j) {
      long long dist = 0;
      if (i <= j) {
        dist = 4 * (j - i) + 2;
      } else {
        dist = 4 * (i - j) - 2;
      }
      dist *= dist;
      cur += dist * c[j];
    }
    if (cur < bestc) {
      bestc = cur;
      col = i;
    }
  }
  best = bestr + bestc;
  cout << best << endl;
  cout << row << " " << col << endl;
  return 0;
}
