#include <bits/stdc++.h>
using namespace std;
int fast_input(void) {
  int x = 0;
  char ch;
  ch = getchar();
  while (ch < '0' && ch > '9') {
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x + x + x + x + x + x + x + x + x + x + ch - '0';
    ch = getchar();
  }
  return x;
}
int X[2], n[2], line[2][1101];
long long cost[2];
long long func(int ele, int g) {
  int i, j;
  long long sum = 0, x;
  ele = ele + ele + ele + ele;
  for (i = 0; i < n[g]; i++) {
    x = i + i + i + i + 2;
    sum += (ele - x) * (ele - x) * line[g][i];
  }
  return sum;
}
void srch2(int left, int right, int g) {
  if (right - left < 3) {
    long long ans, mn = 1e18;
    int id = -1;
    for (int i = left; i <= right; i++) {
      ans = func(i, g);
      if (ans < mn) {
        mn = ans;
        id = i;
      }
    }
    cost[g] = mn;
    X[g] = id;
    return;
  }
  int mid1, mid2;
  mid1 = (left + left + right) / 3;
  mid2 = (left + right + right) / 3;
  if (func(mid1, g) <= func(mid2, g)) {
    srch2(left, mid2, g);
  } else {
    srch2(mid1, right, g);
  }
}
int main() {
  int i, j, a;
  n[0] = fast_input();
  n[1] = fast_input();
  for (i = 0; i < n[0]; i++)
    for (j = 0; j < n[1]; j++) {
      a = fast_input();
      line[0][i] += a;
      line[1][j] += a;
    }
  srch2(0, n[0], 0);
  srch2(0, n[1], 1);
  cout << cost[0] + cost[1] << endl;
  cout << X[0] << " " << X[1] << endl;
}
