#include <bits/stdc++.h>
using namespace std;
int n, m, a[1010][1010];
long long X[1010], Y[1010], costx[1010], costy[1010];
long long sqr(int x) { return 1LL * x * x; }
int main() {
  scanf("%d%d", &n, &m);
  memset(X, 0, sizeof(X));
  memset(Y, 0, sizeof(Y));
  memset(costx, 0, sizeof(costx));
  memset(costy, 0, sizeof(costy));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      X[i] += a[i][j];
      Y[j] += a[i][j];
    }
  }
  for (int i = 0; i <= n; i++) {
    int x = 4 * i;
    for (int j = 1; j <= n; j++) {
      int y = 4 * j - 2;
      costx[i] += X[j] * sqr(x - y);
    }
  }
  for (int i = 0; i <= m; i++) {
    int x = 4 * i;
    for (int j = 1; j <= m; j++) {
      int y = 4 * j - 2;
      costy[i] += Y[j] * sqr(x - y);
    }
  }
  long long ans = costx[0] + costy[0], ansx = 0, ansy = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if (ans > costx[i] + costy[j])
        ans = costx[i] + costy[j], ansx = i, ansy = j;
  printf("%I64d\n", ans);
  printf("%I64d %I64d\n", ansx, ansy);
  return 0;
}
