#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a, b, c, d, e, r;
long long sqr(long long x) { return x * x; }
long long calc(long long x, long long y) {
  return a * sqr(x) + b * sqr(y) + c * x + d * y + e;
}
int main() {
  while (cin >> n >> m) {
    a = b = c = d = e = 0;
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < m; j++) {
        cin >> r;
        a += 16 * r;
        b += 16 * r;
        c -= 8 * r * (4 * i + 2);
        d -= 8 * r * (4 * j + 2);
        e += r * (sqr(4 * i + 2) + sqr(4 * j + 2));
      }
    long long x, y;
    if (a)
      x = -c / (2 * a);
    else
      x = 0;
    if (b)
      y = -d / (2 * b);
    else
      y = 0;
    x = min(x, n - 1);
    x = max(x, 0LL);
    y = min(y, m - 1);
    y = max(y, 0LL);
    long long res = calc(x, y);
    if (calc(x + 1, y) < res) {
      x++;
      res = calc(x, y);
    }
    if (calc(x, y + 1) < res) {
      y++;
      res = calc(x, y);
    }
    cout << res << endl;
    cout << x << " " << y << endl;
  }
  return 0;
}
