#include <bits/stdc++.h>
using namespace std;
long long int mp[1010][1010], sum[1010];
int main() {
  long long int n, m, i, j;
  cin >> n >> m;
  for (i = 1LL; i <= n; i++)
    for (j = 1LL; j <= m; j++) scanf("%I64d", &mp[i][j]);
  for (i = 1LL; i <= n; i++)
    for (j = 1LL; j <= m; j++) sum[i] += mp[i][j];
  long long int ans1 = 1LL << 62LL, ans2 = ans1, X, Y;
  for (i = 0LL; i <= n; i++) {
    long long int t = 0LL;
    for (j = 1LL; j <= n; j++) {
      long long int p = i * 4LL - 4LL * (j - 1LL) - 2LL;
      t += sum[j] * p * p;
    }
    if (t < ans1) {
      ans1 = t;
      X = i;
    }
  }
  memset(sum, 0, sizeof(sum));
  for (j = 1LL; j <= m; j++)
    for (i = 1LL; i <= n; i++) sum[j] += mp[i][j];
  for (j = 0LL; j <= m; j++) {
    long long int t = 0LL;
    for (i = 1LL; i <= m; i++) {
      long long int p = j * 4LL - 4LL * (i - 1LL) - 2LL;
      t += sum[i] * p * p;
    }
    if (t < ans2) {
      ans2 = t;
      Y = j;
    }
  }
  cout << ans1 + ans2 << endl << X << ' ' << Y << endl;
  return 0;
}
