#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  long long cab = 0, ca = 0, cb = 0, c_ = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int c;
      cin >> c;
      int i_ = i << 1 | 1;
      int j_ = j << 1 | 1;
      cab += c;
      ca += c * i_;
      cb += c * j_;
      c_ += (long long)c * (i_ * i_ + j_ * j_);
    }
  cab *= 16;
  ca *= 16;
  cb *= 16;
  c_ *= 4;
  long long ans = INF;
  int a_ = -1, b_ = -1;
  for (int a = 0; a <= n; a++)
    for (int b = 0; b <= m; b++) {
      long long x = cab * (a * a + b * b) - ca * a - cb * b + c_;
      if (ans > x) {
        ans = x;
        a_ = a;
        b_ = b;
      }
    }
  cout << ans << '\n';
  cout << a_ << ' ' << b_ << '\n';
  return 0;
}
