#include <bits/stdc++.h>
using namespace std;
int a[2000][2000];
long long sum[2000];
int main() {
  int i, j, m, n, bi1, bi2;
  long long best1, best2, tmp;
  scanf("%d%d", &m, &n);
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (i = 0; i < m; i++) {
    sum[i] = 0;
    for (j = 0; j < n; j++) sum[i] += a[i][j];
  }
  best1 = 1LL << 60;
  for (i = 0; i <= m; i++) {
    tmp = 0;
    for (j = 0; j < m; j++)
      tmp += (long long)sum[j] * (i * 4 - (j * 4 + 2)) * (i * 4 - (j * 4 + 2));
    if (tmp < best1) {
      best1 = tmp;
      bi1 = i;
    }
  }
  for (i = 0; i < n; i++) {
    sum[i] = 0;
    for (j = 0; j < m; j++) sum[i] += a[j][i];
  }
  best2 = 1LL << 60;
  for (i = 0; i <= n; i++) {
    tmp = 0;
    for (j = 0; j < n; j++)
      tmp += (long long)sum[j] * (i * 4 - (j * 4 + 2)) * (i * 4 - (j * 4 + 2));
    if (tmp < best2) {
      best2 = tmp;
      bi2 = i;
    }
  }
  printf("%I64d\n", best1 + best2);
  printf("%d %d\n", bi1, bi2);
}
