#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10000000000")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007LL;
const long long INF2 = 1000000007LL * 1000000007LL;
const long double EPS = 1e-9;
const int SIZE = 200100;
mt19937 rng(time(0));
uniform_int_distribution<int> uid(-1000000000, 1000000000);
long long n, m, a[1100][1100];
long long sumx[1100], sumy[1100];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      sumx[i] += a[i][j];
      sumy[j] += a[i][j];
    }
  }
  long long x, ansx = INF2;
  for (long long i = 0; i <= n; ++i) {
    long long rs = 0;
    for (long long j = 0; j < n; ++j) {
      rs += sumx[j] * (i * 4 - j * 4 - 2) * (i * 4 - j * 4 - 2);
    }
    if (rs < ansx) {
      x = i;
      ansx = rs;
    }
  }
  long long y, ansy = INF2;
  for (long long i = 0; i <= m; ++i) {
    long long rs = 0;
    for (long long j = 0; j < m; ++j) {
      rs += sumy[j] * (i * 4 - j * 4 - 2) * (i * 4 - j * 4 - 2);
    }
    if (rs < ansy) {
      y = i;
      ansy = rs;
    }
  }
  cout << ansx + ansy << '\n' << x << ' ' << y;
  return 0;
}
