#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1001;
int matrix[MAX_N][MAX_N];
long long r[MAX_N], c[MAX_N];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &matrix[i][j]);
      r[i] += matrix[i][j];
      c[j] += matrix[i][j];
    }
  }
  long long Minx = -1, Miny = -1;
  int x = 0, y = 0;
  for (int i = 0; i <= n; ++i) {
    long long tot = 0;
    for (int j = 0; j < n; ++j) {
      long long d = abs(i - j) * 4 + (j < i ? -2 : 2);
      tot += d * d * r[j];
    }
    if (Minx == -1 || tot < Minx) {
      Minx = tot, x = i;
    }
  }
  for (int i = 0; i <= m; ++i) {
    long long tot = 0;
    for (int j = 0; j < m; ++j) {
      long long d = abs(i - j) * 4 + (j < i ? -2 : 2);
      tot += d * d * c[j];
    }
    if (Miny == -1 || tot < Miny) {
      Miny = tot, y = i;
    }
  }
  printf("%lld\n%d %d\n", Minx + Miny, x, y);
  return 0;
}
