#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
int n, m;
signed long long c[1011][1011];
signed long long ansx = 0x7FFFFFFFFFFFFFFF, ansy = 0x7FFFFFFFFFFFFFFF;
int indx, indy;
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  cin >> n >> m;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++) {
      cin >> c[i][j];
      c[i][1010] += c[i][j];
      c[1010][j] += c[i][j];
    }
  signed long long t;
  for (int k = 0; k < (n + 1); k++) {
    t = 0;
    for (int i = 0; i < (n); i++) {
      if (i < k)
        t += c[i][1010] * (4 * (k - i) - 2) * (4 * (k - i) - 2);
      else
        t += c[i][1010] * (4 * (i - k) + 2) * (4 * (i - k) + 2);
    }
    if (t < ansx) {
      indx = k;
      ansx = t;
    }
  }
  for (int k = 0; k < (m + 1); k++) {
    t = 0;
    for (int j = 0; j < (m); j++) {
      if (j < k)
        t += c[1010][j] * (4 * (k - j) - 2) * (4 * (k - j) - 2);
      else
        t += c[1010][j] * (4 * (j - k) + 2) * (4 * (j - k) + 2);
    }
    if (t < ansy) {
      indy = k;
      ansy = t;
    }
  }
  cout << ansx + ansy << endl << indx << " " << indy;
  return 0;
}
