#include <bits/stdc++.h>
int n, m, X, Y;
long long int c[1005], r[1005], a[1005][1005], MX, MY, cur;
using namespace std;
long long int sqr(long long int a) { return a * a; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf("%I64d", &a[i][j]);
      r[i] += a[i][j];
      c[j] += a[i][j];
    }
  MX = (1LL << 62);
  for (int i = 0; i <= n; i++) {
    cur = 0;
    for (int j = 0; j < i; j++) cur += r[j] * sqr((i - j) * 4 - 2);
    for (int j = i; j < n; j++) cur += r[j] * sqr((j - i) * 4 + 2);
    if (cur < MX) {
      MX = cur;
      X = i;
    }
  }
  MY = (1LL << 62);
  for (int i = 0; i <= m; i++) {
    cur = 0;
    for (int j = 0; j < i; j++) cur += c[j] * sqr((i - j) * 4 - 2);
    for (int j = i; j < m; j++) cur += c[j] * sqr((j - i) * 4 + 2);
    if (cur < MY) {
      MY = cur;
      Y = i;
    }
  }
  printf("%I64d\n%d %d\n", MX + MY, X, Y);
  return 0;
}
