#include <bits/stdc++.h>
using namespace std;
int num[1005][1005];
long long tate[1005];
long long yoko[1005];
int main() {
  srand((unsigned int)time(NULL));
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> num[i][j];
      tate[j] += 1LL * num[i][j];
      yoko[i] += 1LL * num[i][j];
    }
  }
  int x, y;
  long long minx = 1e18;
  long long miny = 1e18;
  for (int i = 0; i <= m; i++) {
    long long sum = 0LL;
    for (int j = 1; j <= m; j++) {
      int f = j * 2 - 1;
      f = abs(f - i * 2);
      f *= 2;
      sum += 1LL * f * f * tate[j];
    }
    if (minx > sum) {
      minx = sum;
      x = i;
    }
  }
  for (int i = 0; i <= n; i++) {
    long long sum = 0LL;
    for (int j = 1; j <= n; j++) {
      int f = j * 2 - 1;
      f = abs(f - i * 2);
      f *= 2;
      sum += 1LL * f * f * yoko[j];
    }
    if (miny > sum) {
      miny = sum;
      y = i;
    }
  }
  cout << minx + miny << endl << y << " " << x << endl;
}
