#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX - 100;
int n, m;
int c[1000][1000];
long long row[1000];
long long col[1000];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &c[i][j]);
      row[i] += c[i][j];
      col[j] += c[i][j];
    }
  }
  long long minxc = +INF;
  int minxi = -1;
  for (int xi = 0; xi <= n; xi++) {
    long long cost = 0;
    for (int i = 0; i < n; i++)
      cost += row[i] * ((4 * i + 2 - 4 * xi) * (4 * i + 2 - 4 * xi));
    if (minxc > cost) {
      minxc = cost;
      minxi = xi;
    }
  }
  long long minyc = +INF;
  int minyj = -1;
  for (int yj = 0; yj <= m; yj++) {
    long long cost = 0;
    for (int j = 0; j < m; j++)
      cost += col[j] * ((4 * j + 2 - 4 * yj) * (4 * j + 2 - 4 * yj));
    if (minyc > cost) {
      minyc = cost;
      minyj = yj;
    }
  }
  printf("%I64d\n%d %d", minxc + minyc, minxi, minyj);
  return 0;
}
