#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long ax = 0, bx = 0, cx = 0;
  long long ay = 0, by = 0, cy = 0;
  long long t = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long c;
      cin >> c;
      ax += c;
      bx -= 2 * (i * 4 + 2) * c;
      cy += c * (i * 4 + 2) * (i * 4 + 2);
      ay += c;
      by -= 2 * (j * 4 + 2) * c;
      cy += c * (j * 4 + 2) * (j * 4 + 2);
    }
  }
  int x = 0, y = 0;
  long long ans = ax * x * x + bx * x + cx + ay * y * y + by * y + cy;
  for (int i = 0; i <= 4 * n; i = i + 4) {
    for (int j = 0; j <= 4 * m; j = j + 4) {
      long long temp =
          ax * (i * i) + bx * (i) + cx + ay * (j * j) + by * j + cy;
      if (temp < ans) {
        ans = temp;
        x = i;
        y = j;
      }
    }
  }
  cout << ans << endl;
  cout << x / 4 << " " << y / 4 << endl;
}
