#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1001][1001] = {0};
int g[1001] = {0};
int v[1001] = {0};
int gd(int pos, int line) {
  if (pos > line)
    return 4 * abs(pos - line - 1) + 2;
  else
    return 4 * (line - pos) + 2;
}
int main() {
  scanf("%d%d\n", &n, &m);
  int i, j;
  for (i = 0; i < n; i++) {
    int s = 0;
    for (j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      s += a[i][j];
    }
    g[i] = s;
  }
  for (j = 0; j < m; j++) {
    int s = 0;
    for (i = 0; i < n; i++) {
      s += a[i][j];
    }
    v[j] = s;
  }
  int li = 0;
  int li_mn = -1;
  long long mn = 1e18;
  for (li = 0; li <= n; li++) {
    long long tmp_s = 0;
    for (i = 0; i < n; i++) {
      int d = gd(li, i);
      tmp_s += (long long)g[i] * d * d;
    }
    if (tmp_s < mn) {
      mn = tmp_s;
      li_mn = li;
    }
  }
  int lj_mn = -1;
  mn = 1e18;
  for (li = 0; li <= m; li++) {
    long long tmp_s = 0;
    for (i = 0; i < m; i++) {
      int d = gd(li, i);
      tmp_s += (long long)v[i] * d * d;
    }
    if (tmp_s < mn) {
      mn = tmp_s;
      lj_mn = li;
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      int dx = gd(li_mn, i);
      int dy = gd(lj_mn, j);
      ans += (long long)a[i][j] * ((dx * dx) + (dy * dy));
    }
  printf("%I64d\n", ans);
  printf("%d %d\n", li_mn, lj_mn);
  return 0;
}
