#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int MOD = 1000000007;
long long C[MAXN][MAXN];
long long X[MAXN], Y[MAXN];
long long SX[MAXN], SY[MAXN];
long long R[MAXN][MAXN];
long long dist(int x0, int y0, int x1, int y1) {
  long long a = (x1 - x0), b = (y1 - y0);
  return a * a + b * b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) cin >> C[i][j];
    memset(Y, 0, sizeof Y);
    memset(X, 0, sizeof X);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) Y[i] += C[i][j], X[j] += C[i][j];
    for (int i = 1; i < m + 1; ++i) {
      SX[i] = 0LL;
      for (int j = 0; j < m; ++j) {
        long long carroX = 4 * j + 2, myX = 4 * i;
        SX[i] += (dist(carroX, 0, myX, 0) - dist(carroX, 0, 0, 0)) * X[j];
      }
    }
    for (int i = 1; i < n + 1; ++i) {
      SY[i] = 0LL;
      for (int j = 0; j < n; ++j) {
        long long carroY = 4 * j + 2, myY = 4 * i;
        SY[i] += (dist(0, carroY, 0, myY) - dist(0, carroY, 0, 0)) * Y[j];
      }
    }
    R[0][0] = 0LL;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        R[0][0] += dist(0, 0, 4 * j + 2, 4 * i + 2) * C[i][j];
      }
    }
    for (int i = 1; i < n + 1; ++i) R[i][0] = R[0][0] + SY[i];
    for (int i = 0; i < n + 1; ++i) {
      for (int j = 1; j < m + 1; ++j) {
        R[i][j] = R[i][0] + SX[j];
      }
    }
    long long best = R[0][0], rx = 0, ry = 0;
    for (int i = 0; i < n + 1; ++i) {
      for (int j = 0; j < m + 1; ++j) {
        if (R[i][j] < best) {
          best = R[i][j];
          ry = i, rx = j;
        }
      }
    }
    cout << best << endl;
    cout << ry << " " << rx << endl;
  }
}
