#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, c[1005][1005], a, b, d, ans, x, y;
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      scanf("%I64d", &c[i][j]);
      a += c[i][j];
      b -= (2 * i - 1) * c[i][j];
      d -= (2 * j - 1) * c[i][j];
    }
  }
  ans = 0x3f3f3f3f3f3f;
  for (i = 0; i <= n; ++i) {
    if (ans > a * i * i + b * i) {
      ans = a * i * i + b * i;
      x = i;
    }
  }
  ans = 0x3f3f3f3f3f3f;
  for (i = 0; i <= m; ++i) {
    if (ans > a * i * i + d * i) {
      ans = a * i * i + d * i;
      y = i;
    }
  }
  ans = 0;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      ans += c[i][j] * (4 * x - 2 * (2 * i - 1)) * (4 * x - 2 * (2 * i - 1)) +
             c[i][j] * (4 * y - 2 * (2 * j - 1)) * (4 * y - 2 * (2 * j - 1));
    }
  }
  printf("%I64d\n%I64d %I64d\n", ans, x, y);
  return 0;
}
