#include <bits/stdc++.h>
const int N = 1000;
int n, m;
long long cost[N][N], pX[N], pY[N];
inline long long fX(int x) {
  long long c = 0;
  for (int i = 0; i < n; i++) {
    c += pX[i] * (long long)(i * 4 + 2 - x * 4) * (i * 4 + 2 - x * 4);
  }
  return c;
}
inline long long fY(int y) {
  long long c = 0;
  for (int i = 0; i < m; i++) {
    c += pY[i] * (long long)(i * 4 + 2 - y * 4) * (i * 4 + 2 - y * 4);
  }
  return c;
}
int main() {
  int a, b;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%I64d", &cost[i][j]);
  }
  for (int i = 0; i < n; i++) {
    pX[i] = 0;
    for (int j = 0; j < m; j++) pX[i] += cost[i][j];
  }
  for (int i = 0; i < m; i++) {
    pY[i] = 0;
    for (int j = 0; j < n; j++) pY[i] += cost[j][i];
  }
  long long l = 0, r = n, m1, m2, c1 = 0, c2 = 0, all = 0;
  a = 0;
  while (l < r) {
    m1 = l + (r - l) / 3;
    m2 = l + (r - l) * 2 / 3;
    if (r - l <= 2) {
      a = l;
      c1 = fX(l);
      c2 = fX(l + 1);
      if (c2 < c1) {
        a = l + 1;
        c1 = c2;
      }
      c2 = fX(l + 2);
      if (c2 < c1) {
        a = l + 2;
        c1 = c2;
      }
      break;
    }
    c1 = fX(m1);
    c2 = fX(m2);
    if (c1 > c2)
      l = m1;
    else
      r = m2;
  }
  all += c1;
  b = 0;
  l = 0;
  r = m;
  while (l < r) {
    m1 = l + (r - l) / 3;
    m2 = l + (r - l) * 2 / 3;
    if (r - l <= 2) {
      b = l;
      c1 = fY(l);
      c2 = fY(l + 1);
      if (c2 < c1) {
        b = l + 1;
        c1 = c2;
      }
      c2 = fY(l + 2);
      if (c2 < c1) {
        b = l + 2;
        c1 = c2;
      }
      break;
    }
    c1 = fY(m1);
    c2 = fY(m2);
    if (c1 > c2)
      l = m1;
    else
      r = m2;
  }
  all += c1;
  printf("%I64d\n", all);
  printf("%d %d\n", a, b);
  return 0;
}
