#include <bits/stdc++.h>
const double eps = 1e-10;
using namespace std;
using ul = unsigned long long;
const int NN = (409);
int m, n, N, x;
int a, b, c;
long long answww;
long long gg;
long long too[1006][1007];
long long cx[1005], cy[1005];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; ++j) {
      scanf("%I64d", &too[i][j]);
      cx[i] += too[i][j];
      cy[j] += too[i][j];
    }
  }
  long long forx = 1000000000000000000LL;
  int low = -1;
  for (int i = 0; i <= n; i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++) {
      int X = 4 * (i - j) - 2;
      sum += X * X * cx[j];
    }
    if (forx > sum) {
      forx = sum;
      low = i;
    }
  }
  long long fory = 1000000000000000000LL;
  int high = -1;
  for (int i = 0; i <= m; i++) {
    long long jam = 0;
    for (int j = 0; j < m; j++) {
      int Y = 4 * (i - j) - 2;
      jam += Y * Y * cy[j];
    }
    if (jam < fory) {
      fory = jam;
      high = i;
    }
  }
  cout << fory + forx << endl;
  cout << low << " " << high << endl;
  return 0;
}
