#include <bits/stdc++.h>
using namespace std;
long long n, m, a[1003][1003], v[1003], h[1003], y, x,
    mnx = 1000000007ll * 1000000007ll, mny = 1000000007ll * 1000000007ll;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf("%lld", a[i] + j);
      h[i] += a[i][j];
      v[j] += a[i][j];
    }
  for (long long i = 0; i <= m; i++) {
    long long sum = 0;
    for (long long j = 0; j < m; j++)
      sum += abs(4 * j - 4 * i + 2) * abs(4 * j - 4 * i + 2) * v[j];
    if (sum < mnx) {
      x = i;
      mnx = sum;
    }
  }
  for (long long i = 0; i <= n; i++) {
    long long sum = 0;
    for (long long j = 0; j < n; j++)
      sum += abs(4 * j - 4 * i + 2) * abs(4 * j - 4 * i + 2) * h[j];
    if (sum < mny) {
      y = i;
      mny = sum;
    }
  }
  cout << mnx + mny << endl;
  cout << y << " " << x << endl;
  return 0;
}
