#include <bits/stdc++.h>
using namespace std;
long long int c[1005][1005], quadratic = 0, single_x = 0, single_y = 0,
                             cnstnt = 0;
void calc_time_function(long long int n, long long int m) {
  long long int i, j, centr_x, centr_y;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      centr_x = i * 4 + 2LL;
      centr_y = j * 4 + 2LL;
      quadratic += c[i][j];
      cnstnt += c[i][j] * (centr_x * centr_x + centr_y * centr_y);
      single_x += (2 * c[i][j] * centr_x);
      single_y += (2 * c[i][j] * centr_y);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int i, j, t, n, m, k, l, r, temp, left, right, mini, maxi, flag,
      leftthird, rightthird, x, y;
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> c[i][j];
  mini = 1e18;
  ;
  calc_time_function(n, m);
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= m; j++) {
      x = i * 4;
      y = j * 4;
      temp = (x * x + y * y) * quadratic - x * single_x - y * single_y + cnstnt;
      if (temp < mini) {
        mini = temp;
        left = i;
        right = j;
      }
    }
  }
  cout << mini << endl;
  cout << left << " " << right << endl;
  return 0;
}
