#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1003], b[1003];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  int ar[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> ar[i][j];
      a[i] += ar[i][j];
      b[j] += ar[i][j];
    }
  }
  long long x = 0, y = 0, mxx = INT64_MAX, mxy = INT64_MAX;
  for (int i = 0; i < n; i++) {
    long long temp = 0;
    for (int j = 0; j < n; j++) {
      temp += (long long)a[j] * ((long long)(j - i) * 4 + 2) *
              ((long long)(j - i) * 4 + 2);
    }
    if (temp < mxx) {
      mxx = temp;
      x = i;
    }
  }
  for (int i = 0; i < m; i++) {
    long long temp = 0;
    for (int j = 0; j < m; j++) {
      temp += (long long)b[j] * ((long long)(j - i) * 4 + 2) *
              ((long long)(j - i) * 4 + 2);
    }
    if (temp < mxy) {
      mxy = temp;
      y = i;
    }
  }
  cout << mxx + mxy << endl;
  cout << x << " " << y << endl;
  return 0;
}
