#include <bits/stdc++.h>
int a[1100][1100];
long long sqr(long long x) { return x * x; }
long long eval(int* v, int p, int n) {
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += sqr(4 * p - (2 + 4 * i)) * v[i];
  }
  return res;
}
int search(int* v, int n) {
  long long res = 0x3f3f3f3f3f3f3f3fLL;
  int i;
  for (i = 0; i <= n; i++) {
    long long at = eval(v, i, n);
    if (at >= res)
      break;
    else
      res = at;
  }
  return i - 1;
}
int v[1100];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  memset(v, 0, sizeof v);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) v[i] += a[i][j];
  }
  int xres = search(v, n);
  long long val = eval(v, xres, n);
  memset(v, 0, sizeof v);
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) v[j] += a[i][j];
  }
  int yres = search(v, m);
  val += eval(v, yres, m);
  printf("%I64d\n%d %d\n", val, xres, yres);
  return 0;
}
