#include <bits/stdc++.h>
using namespace std;
long long n, m, a[1003][1003];
long long sumx[1003][1003], sumy[1003][1003];
long long ansx = 1e18, x, ansy = 1e18, y;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) sumx[i][j] = a[i][j] + sumx[i][j - 1];
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++) sumy[i][j] = a[i][j] + sumy[i - 1][j];
  for (int i = 0; i <= n; i++) {
    long long X = (long long)i * 4;
    long long g = 0;
    for (long long j = 2, k = 1; k <= n; j += 4, k++) {
      long long tx = j;
      g += sumx[k][m] * (X - tx) * (X - tx);
    }
    if (g < ansx) {
      ansx = g;
      x = i;
    }
  }
  for (int i = 0; i <= m; i++) {
    long long Y = (long long)i * 4;
    long long g = 0;
    for (long long j = 2, k = 1; k <= m; j += 4, k++) {
      long long ty = j;
      g += sumy[n][k] * (Y - ty) * (Y - ty);
    }
    if (g < ansy) {
      ansy = g;
      y = i;
    }
  }
  cout << ansx + ansy << endl;
  cout << x << " " << y;
  return 0;
}
