#include <bits/stdc++.h>
using namespace std;
int c[1002][1002];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int x;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &x);
      c[i][j] = x;
    }
  }
  long long s[1002] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      s[i] += c[i][j];
    }
  }
  long long u = (1LL << 61);
  int ai = 0;
  for (int i = 0; i < n; i++) {
    long long t = 0;
    for (int j = 0; j < n; j++) {
      int y = (j - i) * 4 + 2;
      t += s[j] * y * y;
    }
    if (u > t) {
      u = t;
      ai = i;
    }
  }
  memset(s, 0, sizeof(s));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      s[i] += c[j][i];
    }
  }
  long long v = (1LL << 61);
  int aj = 0;
  for (int i = 0; i < m; i++) {
    long long t = 0;
    for (int j = 0; j < m; j++) {
      int y = (j - i) * 4 + 2;
      t += s[j] * y * y;
    }
    if (v > t) {
      v = t;
      aj = i;
    }
  }
  cout << u + v << endl;
  cout << ai << " " << aj << endl;
}
