#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[n + 2][m + 2];
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int n1 = 2, n2 = 2;
  long long val = 0, val1 = 0, val2 = 0, val3 = 0;
  for (n1 = 2; n1 < n * 4; n1 += 4) {
    for (n2 = 2; n2 < m * 4; n2 += 4) {
      int nm1 = (n1 + 2) / 4;
      int nm2 = (n2 + 2) / 4;
      val += 1LL * a[nm1][nm2] * (1LL * n1 * n1 + 1LL * n2 * n2);
      val1 += 1LL * a[nm1][nm2];
      val2 += 1LL * 2 * n1 * a[nm1][nm2];
      val3 += 1LL * 2 * n2 * a[nm1][nm2];
    }
  }
  int ind1, ind2;
  long long ans = 1e+18;
  for (int i = 0; i <= n * 4; i += 4) {
    for (int j = 0; j <= m * 4; j += 4) {
      long long nm1 = 1LL * i * i;
      long long nm2 = 1LL * j * j;
      long long res = 0;
      res = 1LL * val1 * nm1 + 1LL * val1 * nm2;
      res += 1LL * val;
      res = res - 1LL * i * val2;
      res = res - 1LL * j * val3;
      if (res == ans) {
        if (i < ind1) {
          ind1 = i;
          ind2 = j;
        }
      }
      if (res < ans) {
        ans = res;
        ind1 = i;
        ind2 = j;
      }
    }
  }
  cout << ans << "\n";
  cout << ind1 / 4 << " " << ind2 / 4 << endl;
  return 0;
}
