#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 5;
const long long INF = 1e18;
int n, m, l;
struct data {
  int v, f, c;
} a[MAX];
long long sq(int x) { return x * 1LL * x; }
long long f1(int f) {
  f *= 4;
  long long sol = 0;
  for (int i = 1; i <= l; i++) {
    sol += sq((f - a[i].f)) * 1LL * a[i].v;
  }
  return sol;
}
long long f2(int c) {
  c *= 4;
  long long sol = 0;
  for (int i = 1; i <= l; i++) {
    sol += sq((c - a[i].c)) * 1LL * a[i].v;
  }
  return sol;
}
long long f3(int f, int c) {
  f *= 4, c *= 4;
  long long sol = 0;
  for (int i = 1; i <= l; i++) {
    sol += (sq((c - a[i].c)) + sq(f - a[i].f)) * 1LL * a[i].v;
  }
  return sol;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[++l].v);
      a[l].f = 4 * (i - 1) + 2;
      a[l].c = 4 * (j - 1) + 2;
    }
  }
  int st = 0, nd = n;
  int f = 1e9, c = 1e9;
  while (st <= nd) {
    int mid = (st + nd) >> 1;
    long long v = f1(mid);
    if (v <= f1(mid + 1)) {
      f = min(f, mid);
      nd = mid - 1;
    } else
      st = mid + 1;
  }
  st = 0, nd = m;
  while (st <= nd) {
    int mid = (st + nd) >> 1;
    long long v = f2(mid);
    if (v <= f2(mid + 1)) {
      c = min(c, mid);
      nd = mid - 1;
    } else
      st = mid + 1;
  }
  printf("%lld\n", f3(f, c));
  printf("%d %d\n", f, c);
  return 0;
}
