#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005, oo = 2147483645;
long long n, m, a[maxn][maxn], sumx[maxn], sumy[maxn], ans, ansx, ansy;
void init() {
  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] += a[i][j];
  }
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) sumy[i] += a[j][i];
  }
}
void solvex() {
  long long cost, tmp;
  cost = oo;
  cost = cost * cost;
  for (int i = 0; i <= 4 * n; i += 4) {
    tmp = 0;
    for (int j = 1; j <= n; j++)
      tmp = tmp + sumx[j] * (i - 4 * j + 2) * (i - 4 * j + 2);
    if (tmp < cost) {
      cost = tmp;
      ansx = i / 4;
    }
  }
  ans += cost;
}
void solvey() {
  long long cost, tmp;
  cost = oo;
  cost = cost * cost;
  for (int i = 0; i <= 4 * m; i += 4) {
    tmp = 0;
    for (int j = 1; j <= m; j++)
      tmp = tmp + sumy[j] * (i - 4 * j + 2) * (i - 4 * j + 2);
    if (tmp < cost) {
      cost = tmp;
      ansy = i / 4;
    }
  }
  ans += cost;
}
int main() {
  init();
  ans = 0;
  solvex();
  solvey();
  cout << ans << endl << ansx << " " << ansy << endl;
  return 0;
}
