#include <bits/stdc++.h>
using namespace std;
long long row[1005], col[1005];
const long long LINF = 0x7fffffffffffffff;
int main() {
  int n, m;
  long long temp, t;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%I64d", &temp);
      row[i] += temp;
      col[j] += temp;
    }
  }
  int dx, dy;
  long long result1 = LINF, result2 = LINF;
  for (int i = 0; i <= m; i++) {
    temp = 0;
    for (int j = 1; j <= m; j++) {
      if (j <= i)
        t = 2 + (i - j) * 4;
      else
        t = 2 + (j - i - 1) * 4;
      temp += t * t * col[j];
    }
    if (result1 > temp) {
      result1 = temp;
      dx = i;
    }
  }
  for (int i = 0; i <= n; i++) {
    temp = 0;
    for (int j = 1; j <= n; j++) {
      if (j <= i)
        t = 2 + (i - j) * 4;
      else
        t = 2 + (j - i - 1) * 4;
      temp += t * t * row[j];
    }
    if (result2 > temp) {
      result2 = temp;
      dy = i;
    }
  }
  printf("%I64d\n", result1 + result2);
  printf("%d %d\n", dy, dx);
  return 0;
}
