#include <bits/stdc++.h>
using namespace std;
long long int sqr(long long int x) { return (x * x); }
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  long long int sumC = 0;
  double sumX = 0, sumY = 0;
  vector<vector<int> > C(n);
  for (int i = (0); i <= ((int)(C).size() - 1); ++i) C[i].resize(m, 0);
  for (int i = (0); i <= (n - 1); ++i)
    for (int j = (0); j <= (m - 1); ++j) {
      cin >> C[i][j];
      sumC += C[i][j];
      sumX += ((double)i + 0.5) * C[i][j];
      sumY += ((double)j + 0.5) * C[i][j];
    }
  if (!sumC) {
    cout << "0\n0 0";
    return 0;
  }
  double X = sumX / sumC;
  double Y = sumY / sumC;
  int checkX[] = {(int)(X - 0.5), (int)X, (int)(X + 0.5)},
      checkY[] = {(int)(Y - 0.5), (int)Y, (int)(Y + 0.5)};
  int bestX = 0, bestY = 0;
  long long int ans = 1000000000000000001;
  for (int ix = (0); ix <= (2); ++ix)
    for (int iy = (0); iy <= (2); ++iy) {
      int x = checkX[ix], y = checkY[iy];
      long long int here = 0;
      for (int i = (0); i <= (n - 1); ++i)
        for (int j = (0); j <= (m - 1); ++j) {
          here += C[i][j] * sqr(4 * i + 2 - 4 * x);
          here += C[i][j] * sqr(4 * j + 2 - 4 * y);
        }
      if (here < ans) {
        ans = here;
        bestX = x;
        bestY = y;
      }
    }
  cout << ans << '\n' << bestX << ' ' << bestY;
  return 0;
}
