#include <bits/stdc++.h>
using namespace std;
long long field[1005][1005];
int M, N;
long long xsum[1005], ysum[1005];
long long checkx(long long thisx) {
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    long long curdist = thisx * 4 - (4 * i + 2);
    sum += curdist * curdist * xsum[i];
  }
  return sum;
}
long long checky(long long thisy) {
  long long sum = 0;
  for (int i = 0; i < M; i++) {
    long long curdist = thisy * 4 - (4 * i + 2);
    sum += curdist * curdist * ysum[i];
  }
  return sum;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M;
  memset(xsum, 0, sizeof(xsum));
  memset(ysum, 0, sizeof(ysum));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> field[i][j];
      xsum[i] += field[i][j];
      ysum[j] += field[i][j];
    }
  }
  long long ansx, ansy;
  long long curxval = LLONG_MAX, curyval = LLONG_MAX;
  for (int i = N; i >= 0; i--) {
    long long ans1 = checkx(i);
    if (ans1 <= curxval) {
      ansx = i;
      curxval = ans1;
    }
  }
  for (int i = M; i >= 0; i--) {
    long long ans1 = checky(i);
    if (ans1 <= curyval) {
      ansy = i;
      curyval = ans1;
    }
  }
  cout << checkx(ansx) + checky(ansy) << endl;
  cout << ansx << " " << ansy << endl;
}
