#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int INF = 1000000000;
const long long oo = 0x7fffffffffffffff;
int n, m;
long long sumd, sumx, sumy, sumc;
long long f(int x, int y) {
  return sumd - 2 * sumx * (long long)x - 2 * sumy * (long long)y +
         sumc * (long long)(x * x + y * y);
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    sumd = sumx = sumy = 0;
    int c;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        scanf("%d", &c);
        sumc += (long long)c;
        int x = 2 + 4 * i, y = 2 + 4 * j;
        sumx += (long long)c * (long long)x;
        sumy += (long long)c * (long long)y;
        sumd += (long long)c * (long long)(x * x + y * y);
      }
    }
    long long ans = oo;
    int ansx, ansy;
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j <= m; ++j) {
        long long temp = f(i * 4, j * 4);
        if (ans > temp) {
          ans = temp;
          ansx = i, ansy = j;
        }
      }
    }
    printf("%I64d\n%d %d\n", ans, ansx, ansy);
  }
  return 0;
}
