#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[1005][1005];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  long long chX[1005], chY[1005];
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < m; j++) sum += a[i][j];
    chX[i] = sum;
  }
  for (int j = 0; j < m; j++) {
    long long sum = 0;
    for (int i = 0; i < n; i++) sum += a[i][j];
    chY[j] = sum;
  }
  long long minX = 1e18, minY = 1e18;
  int xCoor = 0, yCoor = 0;
  for (int i = 0; i <= n; i++) {
    long long sum = 0;
    for (int j = 0; j < n; j++)
      sum += (i * 4 - j * 4 - 2) * (i * 4 - j * 4 - 2) * chX[j];
    if (sum < minX) minX = sum, xCoor = i;
  }
  for (int i = 0; i <= m; i++) {
    long long sum = 0;
    for (int j = 0; j < m; j++)
      sum += (i * 4 - j * 4 - 2) * (i * 4 - j * 4 - 2) * chY[j];
    if (sum < minY) minY = sum, yCoor = i;
  }
  cout << minY + minX << endl << xCoor << " " << yCoor << endl;
}
