#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
long long int mx[2000][2000], det[2000][2000];
pair<long long int, long long int> was[2000];
long long int n, m;
long long int sqr(long long int a) { return a * a; }
long long int geti(long long int x, long long int y) {
  if (det[x][y] != -1) return det[x][y];
  x *= 4;
  y *= 4;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++)
    for (long long int j = 0; j < m; j++)
      ans += (sqr(i * 4 + 2 - x) + sqr(j * 4 + 2 - y)) * mx[i][j];
  return det[x / 4][y / 4] = ans;
}
pair<long long int, long long int> ter2(long long int x) {
  if (was[x] != make_pair((long long int)-1, (long long int)-1)) return was[x];
  long long int l = 0, r = m;
  while (r - l > 3) {
    long long int a = (l * 2 + r) / 3, b = (l + r * 2) / 3;
    if (geti(x, a) > geti(x, b))
      l = a;
    else
      r = b;
  }
  long long int ans = 1e18, good = -1;
  for (; l <= r; l++) {
    long long int val;
    if (ans > (val = geti(x, l))) {
      ans = val;
      good = l;
    }
  }
  return was[x] = make_pair(ans, good);
}
int main() {
  cin >> n >> m;
  for (long long int i = 0; i <= n; i++) {
    was[i] = make_pair(-1, -1);
    for (long long int j = 0; j <= m; j++) det[i][j] = -1;
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      scanf("%I64d", &mx[i][j]);
    }
  }
  long long int l = 0, r = n;
  while (r - l > 3) {
    long long int a = (l * 2 + r) / 3, b = (l + r * 2) / 3;
    if (geti(a, 0) > geti(b, 0))
      l = a;
    else
      r = b;
  }
  long long int ans = 1e18;
  pair<long long int, long long int> ou;
  for (; l <= r; l++) {
    pair<long long int, long long int> val;
    val = ter2(l);
    if (ans > val.first) {
      ans = val.first;
      ou = make_pair(l, val.second);
    }
  }
  cout << ans << endl << ou.first << " " << ou.second;
}
