#include <bits/stdc++.h>
using namespace std;
int H, W;
long long C[1010][1010];
long long sqr(long long x) { return x * x; }
int main() {
  while (2 == scanf("%d%d", &H, &W)) {
    for (int y = 0; y < (int)(H); y++)
      for (int x = 0; x < (int)(W); x++) {
        int c;
        scanf("%d", &c);
        C[y][x] = c;
      }
    long long byp = -1, byt = 1LL << 60;
    long long cs[1010];
    for (int y = 0; y < (int)(H); y++) {
      cs[y] = 0;
      for (int x = 0; x < (int)(W); x++) cs[y] += C[y][x];
    }
    for (int y = 0; y <= H; ++y) {
      long long t = 0;
      for (int i = 0; i < (int)(H); i++) t += cs[i] * sqr(y * 4 - (i * 4 + 2));
      if (t < byt) {
        byp = y;
        byt = t;
      }
    }
    long long bxp = -1, bxt = 1LL << 60;
    for (int x = 0; x < (int)(W); x++) {
      cs[x] = 0;
      for (int y = 0; y < (int)(H); y++) cs[x] += C[y][x];
    }
    for (int x = 0; x <= W; ++x) {
      long long t = 0;
      for (int j = 0; j < (int)(W); j++) t += cs[j] * sqr(x * 4 - (j * 4 + 2));
      if (t < bxt) {
        bxp = x;
        bxt = t;
      }
    }
    cout << (byt + bxt) << endl;
    cout << byp << " " << bxp << endl;
  }
  return 0;
}
