#include <bits/stdc++.h>
using namespace std;
int n, m;
long long c[1010][1010];
int main() {
  while (cin >> n >> m) {
    long long totC = 0LL;
    long long totCX = 0LL;
    long long totCY = 0LL;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        scanf("%I64d", &c[i][j]);
        totC += c[i][j];
        totCX += (4LL * (long long)i + 2LL) * c[i][j];
        totCY += (4LL * (long long)j + 2LL) * c[i][j];
      }
    }
    long long init = 0LL;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        long long tmp =
            (4LL * (long long)i + 2LL) * (4LL * (long long)i + 2LL) +
            (4LL * (long long)j + 2LL) * (4LL * (long long)j + 2LL);
        init += tmp * c[i][j];
      }
    }
    long long ans = init;
    int posi = 0;
    int posj = 0;
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j <= m; ++j) {
        if (i == 0 && j == 0) continue;
        long long dx = 4 * i;
        long long dy = 4 * j;
        long long tmp = init + dx * dx * totC + dy * dy * totC -
                        2LL * dx * totCX - 2LL * dy * totCY;
        if (tmp < ans) {
          ans = tmp;
          posi = i;
          posj = j;
        }
      }
    }
    printf("%I64d\n", ans);
    cout << posi << " " << posj << endl;
  }
  return 0;
}
