#include <bits/stdc++.h>
using namespace std;
long long r[1010], c[1010];
int a[1010][1010];
long long x[1010], y[1010], ac[1010], ar[1010];
int main() {
  int i, j, m, n, k, t;
  while (cin >> n >> m) {
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++)
        scanf("%d", &a[i][j]), ar[i] += a[i][j], ac[j] += a[i][j];
    for (i = 1; i <= n; i++) x[i] = (i - 1) * 4 + 2;
    for (j = 1; j <= m; j++) y[j] = (j - 1) * 4 + 2;
    for (k = 0; k <= n; k++)
      for (i = 1; i <= n; i++) r[k] += (x[i] - k * 4) * (x[i] - k * 4) * ar[i];
    for (k = 0; k <= m; k++)
      for (i = 1; i <= m; i++) c[k] += (y[i] - k * 4) * (y[i] - k * 4) * ac[i];
    long long Min = 1123456789987654321ll, Minx, Miny;
    for (i = 0; i <= n; i++)
      for (j = 0; j <= m; j++)
        if (r[i] + c[j] < Min) Min = r[i] + c[j], Minx = i, Miny = j;
    cout << Min << endl;
    cout << Minx << ' ' << Miny << endl;
  }
}
