#include <bits/stdc++.h>
using namespace std;
int car[1001][1001];
long long si[1001] = {0}, sj[1001] = {0};
int main() {
  int n, m, li, lj;
  long long sumx, sumy;
  scanf("%d %d", &n, &m);
  for (int j = 1; j <= n; j++) {
    for (int i = 1; i <= m; i++) {
      scanf("%d", &car[j][i]);
      si[i] += car[j][i];
      sj[j] += car[j][i];
    }
  }
  sumx = sumy = 9223372036854775807;
  for (int x = 0; x <= 4 * m; x += 4) {
    long long tmp = 0;
    for (int i = 1; i <= m; i++) {
      tmp = tmp + si[i] * (x - 4 * i + 2) * (x - 4 * i + 2);
    }
    if (tmp < sumx) {
      sumx = tmp;
      lj = x / 4;
    }
  }
  for (int y = 0; y <= 4 * n; y += 4) {
    long long tmp = 0;
    for (int j = 1; j <= n; j++) {
      tmp = tmp + sj[j] * (y - 4 * j + 2) * (y - 4 * j + 2);
    }
    if (tmp < sumy) {
      sumy = tmp;
      li = y / 4;
    }
  }
  printf("%I64d\n%d %d\n", sumx + sumy, li, lj);
  return 0;
}
