#include <bits/stdc++.h>
using namespace std;
int sumi[1010], sumj[1010];
int n, m;
int main() {
  cin.sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int cur;
      cin >> cur;
      sumi[i] += cur;
      sumj[j] += cur;
    }
  int besti, bestj;
  long long vali = 5 * 1e18, valj = 5 * 1e18;
  for (int t = 0; t <= n; t++) {
    long long val = 0;
    for (int i = 1; i <= n; i++) {
      val += static_cast<long long>(4 * i - 2 - 4 * t) * (4 * i - 2 - 4 * t) *
             sumi[i - 1];
    }
    if (val < vali) {
      vali = val;
      besti = t;
    }
  }
  for (int t = 0; t <= m; t++) {
    long long val = 0;
    for (int j = 1; j <= m; j++) {
      val += static_cast<long long>(4 * j - 2 - 4 * t) * (4 * j - 2 - 4 * t) *
             sumj[j - 1];
    }
    if (val < valj) {
      valj = val;
      bestj = t;
    }
  }
  cout << valj + vali << endl << besti << " " << bestj << endl;
  return 0;
}
