#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
int rar[MAXN][MAXN];
int sr[2][MAXN];
int mini[2];
long long gao(int sri, int len) {
  long long ret = -1;
  for (int i = 0; i < len; ++i) {
    long long sum = 0;
    for (int j = 0; j < len; ++j) {
      int d = abs(2 * j + 1 - 2 * i);
      sum += (long long)sr[sri][j] * d * d;
    }
    sum *= 4;
    if (ret == -1 || ret > sum) {
      ret = sum;
      mini[sri] = i;
    }
  }
  return ret;
}
int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(sr, sizeof(sr), 0);
  for (int i = 0; i != n; ++i) {
    for (int j = 0; j != m; ++j) {
      scanf("%d", &(rar[i][j]));
      sr[0][i] += rar[i][j];
      sr[1][j] += rar[i][j];
    }
  }
  cout << gao(0, n) + gao(1, m) << endl;
  cout << mini[0] << ' ' << mini[1] << endl;
  return 0;
}
