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