#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1100;
const long long LLinf = 1000000000000000000LL;
int A[SIZE][SIZE];
long long AN[SIZE], AM[SIZE];
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i != N; i++)
    for (int j = 0; j != M; j++)
      scanf("%d", &A[i][j]), AN[i] += A[i][j], AM[j] += A[i][j];
  long long rN = LLinf, iN = 0, r;
  for (int i = 0; i != N + 1; i++) {
    r = 0;
    for (int j = 0; j != N; j++)
      if (j >= i)
        r += AN[j] * (2LL + 4 * (j - i)) * (2LL + 4 * (j - i));
      else
        r += AN[j] * (-2LL + 4 * (i - j)) * (-2LL + 4 * (i - j));
    if (rN > r) rN = r, iN = i;
  }
  long long rM = LLinf, iM = 0;
  for (int i = 0; i != M + 1; i++) {
    r = 0;
    for (int j = 0; j != M; j++)
      if (j >= i)
        r += AM[j] * (2LL + 4 * (j - i)) * (2LL + 4 * (j - i));
      else
        r += AM[j] * (-2LL + 4 * (i - j)) * (-2LL + 4 * (i - j));
    if (rM > r) rM = r, iM = i;
  }
  cout << rN + rM << endl << iN << ' ' << iM;
  return 0;
}
