#include <bits/stdc++.h>
using namespace std;
int n, m;
long long i, j, m1[1000][1000], m2[1001], m3[1001], ansx, ansy, a1, a2;
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      cin >> m1[i][j];
      m2[i] += m1[i][j];
      m3[j] += m1[i][j];
    }
  ansx = 1ll << 60;
  for (i = 0; i <= n; i++) {
    long long tmp = 0;
    for (j = 0; j < n; j++) {
      tmp += m2[j] * (i * 4 - (j * 4 + 2)) * (i * 4 - (j * 4 + 2));
    }
    if (tmp < ansx) {
      ansx = tmp;
      a1 = i;
    }
  }
  ansy = 1ll << 60;
  for (i = 0; i <= m; i++) {
    long long tmp = 0;
    for (j = 0; j < m; j++) {
      tmp += m3[j] * (i * 4 - (j * 4 + 2)) * (i * 4 - (j * 4 + 2));
    }
    if (tmp < ansy) {
      ansy = tmp;
      a2 = i;
    }
  }
  cout << ansx + ansy << endl << a1 << ' ' << a2 << endl;
  return 0;
}
