#include <bits/stdc++.h>
using namespace std;
int c[1000][1000], n, m;
long long col[1000], row[1000];
long long sqr(int x) { return (long long)x * x; }
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(col, 0, sizeof(col));
    memset(row, 0, sizeof(row));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        scanf("%d", &c[i][j]);
        row[i] += c[i][j];
        col[j] += c[i][j];
      }
    int x = 0, y = 0;
    long long maxx = 1LL << 60, maxy = 1LL << 60;
    for (int i = 0; i <= n; i++) {
      long long tmp = 0;
      for (int j = 0; j < i; j++) tmp += row[j] * sqr((abs(i - j - 1) * 4 + 2));
      for (int j = i; j < n; j++) tmp += row[j] * sqr((abs(j - i) * 4 + 2));
      if (tmp < maxx) {
        x = i;
        maxx = tmp;
      }
    }
    for (int i = 0; i <= m; i++) {
      long long tmp = 0;
      for (int j = 0; j < i; j++) tmp += col[j] * sqr((abs(i - j - 1) * 4 + 2));
      for (int j = i; j < m; j++) tmp += col[j] * sqr((abs(j - i) * 4 + 2));
      if (tmp < maxy) {
        y = i;
        maxy = tmp;
      }
    }
    printf("%I64d\n", maxx + maxy);
    printf("%d %d\n", x, y);
  }
  return 0;
}
