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