#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
int C[MAXN][MAXN];
int N, M;
long long CR[MAXN];
int ansX, ansY;
long long calc(int x) {
  long long ret = 0;
  for (int i = 1; i <= N; ++i) {
    long long d = (i > x ? i - x - 1 : x - i) * 4 + 2;
    ret += CR[i] * d * d;
  }
  return ret;
}
long long solve() {
  for (int i = 1; i <= N; ++i) {
    CR[i] = 0;
    for (int j = 1; j <= M; ++j) {
      CR[i] += C[i][j];
    }
  }
  long long ret = calc(0);
  int idx = 0;
  for (int i = 0; i <= N; ++i) {
    long long tmp = calc(i);
    if (tmp < ret) {
      ret = tmp;
      idx = i;
    }
  }
  if (ansX == -1)
    ansX = idx;
  else
    ansY = idx;
  return ret;
}
int main() {
  while (cin >> N >> M) {
    for (int i = 1; i <= N; ++i)
      for (int j = 1; j <= M; ++j) scanf("%d", &C[i][j]);
    ansX = ansY = -1;
    long long ans = solve();
    for (int i = 1; i <= max(N, M); ++i)
      for (int j = 0; j <= i; ++j) swap(C[i][j], C[j][i]);
    swap(N, M);
    cout << ans + solve() << endl;
    cout << ansX << " " << ansY << endl;
  }
  return 0;
}
