#include <bits/stdc++.h>
using namespace std;
long long dp[1010][1010];
long long n, m;
long long c[1010][1010];
long long sum_c, sum_qc, sum_pc;
inline long long sqr(long long x) { return (x * x); }
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  dp[0][0] = 0;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> c[i][j];
      sum_c += c[i][j];
      long long cx = (4 * i + 2);
      long long cy = (4 * j + 2);
      sum_pc += c[i][j] * cx;
      sum_qc += c[i][j] * cy;
      dp[0][0] += c[i][j] * (cx * cx + cy * cy);
    }
  }
  for (long long i = 0; i < n; i++) {
    dp[i + 1][0] = dp[i][0] + (8 * sum_c * 4 * i) + (16 * sum_c) - (8 * sum_pc);
  }
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j < m; j++) {
      dp[i][j + 1] =
          dp[i][j] + (8 * sum_c * 4 * j) + (16 * sum_c) - (8 * sum_qc);
    }
  }
  long long mn = 1e18;
  long long li, lj;
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= m; j++) {
      if (mn > dp[i][j]) {
        mn = dp[i][j];
        li = i;
        lj = j;
      }
    }
  }
  cout << mn << '\n';
  cout << li << " " << lj << '\n';
  return 0;
}
