#include <bits/stdc++.h>
using namespace std;
const long long inf = numeric_limits<long long>::max();
const long long mod = 1e9 + 7;
long long line[1 << 10], col[1 << 10];
long long ansl = inf, ansc = inf;
pair<int, int> ans;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long c;
      scanf("%I64d", &c);
      line[i] += c;
      col[j] += c;
    }
  }
  for (int i = 0; i <= n; i++) {
    long long cur = 0;
    for (int j = 0; j < n; j++) {
      int v = j;
      if (j < i) v++;
      cur += line[j] * (abs(v - i) * 4 + 2) * (abs(v - i) * 4 + 2);
    }
    if (ansl > cur) ansl = cur, ans.first = i;
  }
  for (int i = 0; i <= m; i++) {
    long long cur = 0;
    for (int j = 0; j < m; j++) {
      int v = j;
      if (j < i) v++;
      cur += col[j] * (abs(v - i) * 4 + 2) * (abs(v - i) * 4 + 2);
    }
    if (ansc > cur) ansc = cur, ans.second = i;
  }
  printf("%I64d\n%d %d", ansl + ansc, ans.first, ans.second);
  return 0;
}
