#include <bits/stdc++.h>
using namespace std;
bool deb = false;
const int N = 1011;
pair<long long int, long long int> a[N][N], mat[N][N];
long long int c[N][N], m, n;
void mm() {
  long long int i, j, ii = 2, jj = 2;
  for (i = 1; i < n + 1; ++i) {
    jj = 2;
    for (j = 1; j < m + 1; ++j) {
      mat[i][j] = make_pair(ii, jj);
      jj += 4;
    }
    ii += 4;
  }
  ii = 0, jj = 0;
  for (i = 0; i < n + 1; ++i) {
    jj = 0;
    for (j = 0; j < m + 1; ++j) {
      a[i][j] = make_pair(ii, jj);
      jj += 4;
    }
    ii += 4;
  }
  long long int v1x = 0, v2x = 0;
  long long int v1y = 0, v2y = 0;
  long long int sum = 0;
  for (i = 1; i < n + 1; ++i) {
    for (j = 1; j < m + 1; ++j) {
      v1x += 2 * c[i][j] * mat[i][j].first;
      v1y += 2 * c[i][j] * mat[i][j].second;
      v2x += c[i][j] * ((mat[i][j].first) * (mat[i][j].first));
      v2y += c[i][j] * ((mat[i][j].second) * (mat[i][j].second));
      sum += c[i][j];
    }
  }
  unsigned long long mn = 9000000000000000000;
  pair<long long int, long long int> pt;
  for (i = 0; i < n + 1; ++i) {
    for (j = 0; j < m + 1; ++j) {
      unsigned long long dt =
          sum * ((a[i][j].first) * (a[i][j].first)) - v1x * a[i][j].first + v2x;
      dt += sum * ((a[i][j].second) * (a[i][j].second)) - v1y * a[i][j].second +
            v2y;
      if (dt == mn) {
        if (pt.first > i) {
          pt = make_pair(i, j);
        } else if (pt.first == i) {
          if (pt.second > j) {
            pt = make_pair(i, j);
          }
        }
      } else if (dt < mn) {
        mn = dt;
        pt = make_pair(i, j);
      }
    }
  }
  printf("%llu\n", mn);
  printf("%lld ", pt.first), printf("%lld\n", pt.second);
}
int main() {
  long long int i, j;
  scanf("%lld", &n), scanf("%lld", &m);
  for (i = 1; i < n + 1; ++i) {
    for (j = 1; j < m + 1; ++j) {
      scanf("%lld", &c[i][j]);
    }
  }
  mm();
  return 0;
}
