#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x[n], y[m], c[n][m];
  for (int i = 0; i <= n - 1; i++) {
    for (int j = 0; j <= m - 1; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i <= n - 1; i++) {
    x[i] = 4 * i + 2;
  }
  for (int j = 0; j <= m - 1; j++) {
    y[j] = 4 * j + 2;
  }
  long long sumX[n];
  long long sumY[m];
  for (int i = 0; i <= n - 1; i++) {
    sumX[i] = 0;
    for (int j = 0; j <= m - 1; j++) {
      sumX[i] += c[i][j];
    }
  }
  for (int j = 0; j <= m - 1; j++) {
    sumY[j] = 0;
    for (int i = 0; i <= n - 1; i++) {
      sumY[j] += c[i][j];
    }
  }
  long long resx = 7000000000000000000LL;
  int indexX;
  int dis;
  long long S, sum;
  for (int k = 0; k <= n; k++) {
    dis = k * 4;
    S = 0;
    for (int i = 0; i <= n - 1; i++) {
      S += sumX[i] * (abs(dis - x[i]) * abs(dis - x[i]));
    }
    if (S < resx) {
      resx = S;
      indexX = k;
    }
  }
  long long resy = 7000000000000000000LL;
  int indexY;
  for (int k = 0; k <= m; k++) {
    int dis = k * 4;
    S = 0;
    for (int j = 0; j <= m - 1; j++) {
      S += sumY[j] * (abs(dis - y[j]) * abs(dis - y[j]));
    }
    if (S < resy) {
      resy = S;
      indexY = k;
    }
  }
  cout << resx + resy << "\n" << indexX << " " << indexY << "\n";
  return 0;
}
