#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1024;
const long long INF = 1e18;
int N, M;
long long rare[MAXN][MAXN];
long long row[MAXN], col[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0), cout.precision(15);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> rare[i][j];
      row[i] += rare[i][j];
      col[j] += rare[i][j];
    }
  }
  long long xc = INF, bx = -1;
  for (int x = 0; x <= N; x++) {
    long long mc = 0;
    for (int r = 0; r < N; r++) {
      long long d = 4 * abs(x - r);
      if (r < x)
        d -= 2;
      else
        d += 2;
      mc += d * d * row[r];
    }
    if (mc < xc) {
      xc = mc;
      bx = x;
    }
  }
  long long yc = INF, by = -1;
  for (int y = 0; y <= M; y++) {
    long long mc = 0;
    for (int c = 0; c < M; c++) {
      long long d = 4 * abs(y - c);
      if (c < y)
        d -= 2;
      else
        d += 2;
      mc += d * d * col[c];
    }
    if (mc < yc) {
      yc = mc;
      by = y;
    }
  }
  cout << xc + yc << "\n";
  cout << bx << " " << by << "\n";
}
