#include <bits/stdc++.h>
using namespace std;
int arr[1001][1001];
int main() {
  int n, m;
  long long sum = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      scanf("%d", &arr[i][j]), sum += (long long)arr[i][j];
  long long toaddx = 0, toaddy = 0, toaddx2 = 0, toaddy2 = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      long long cur = i * 4 + 2;
      long long cur2 = j * 4 + 2;
      toaddx += cur * cur * arr[i][j];
      toaddx2 += cur * arr[i][j];
      toaddy2 += cur2 * arr[i][j];
      toaddy += cur2 * cur2 * arr[i][j];
    }
  long long ans = LLONG_MAX;
  pair<int, int> PlacesToPrint = make_pair(0, 0);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      long long curans =
          (long long)(i * 4) * (i * 4) * sum + toaddx - (2 * (i * 4) * toaddx2);
      curans +=
          (long long)(j * 4) * (j * 4) * sum + toaddy - (2 * (j * 4) * toaddy2);
      if (curans < ans) {
        ans = curans;
        PlacesToPrint = make_pair(i, j);
      }
    }
  }
  printf("%I64d\n", ans);
  printf("%d %d\n", PlacesToPrint.first, PlacesToPrint.second);
  return 0;
}
