#include <bits/stdc++.h>
using namespace std;
int a[1001][1001];
long long a1[1001];
long long a2[1001];
int n, m;
long long sqr(long long x) { return x * x; }
long long get1(int x) {
  long long res = 0;
  for (int i = 1; i <= n; i++) res += a1[i] * (4 + 16ll * (x - i + sqr(x - i)));
  return res;
}
long long get2(int x) {
  long long res = 0;
  for (int i = 1; i <= m; i++) res += a2[i] * (4 + 16ll * (x - i + sqr(x - i)));
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      a1[i] += a[i][j];
      a2[j] += a[i][j];
    }
  long long ans1 = 1000000000ll * 1000000000ll;
  long long ans2 = 1000000000ll * 1000000000ll;
  int k1 = -1;
  int k2 = -2;
  for (int i = 0; i <= n; i++) {
    long long k = get1(i);
    if (k < ans1) {
      ans1 = k;
      k1 = i;
    }
  }
  for (int j = 0; j <= m; j++) {
    long long k = get2(j);
    if (k < ans2) {
      ans2 = k;
      k2 = j;
    }
  }
  cout << ans1 + ans2 << "\n" << k1 << ' ' << k2 << "\n";
}
