#include <bits/stdc++.h>
using namespace std;
const int MAX = 1010;
int R, C;
int W[MAX][MAX];
int main() {
  scanf("%d%d", &R, &C);
  for (int i = 0; i < (R); ++i)
    for (int j = 0; j < (C); ++j) scanf("%d", &W[i][j]);
  long long add = 0;
  long long fx = 0;
  long long fy = 0;
  long long sum_W = 0;
  for (int i = 0; i < (R); ++i)
    for (int j = 0; j < (C); ++j) {
      long long x = 4 * i + 2;
      long long y = 4 * j + 2;
      add += (x * x + y * y) * W[i][j];
      fx -= 2 * x * W[i][j];
      fy -= 2 * y * W[i][j];
      sum_W += W[i][j];
    }
  long long ans = 1LL << 60;
  int ans_i = -1;
  int ans_j = -1;
  for (int i = 0; i < (R + 1); ++i)
    for (int j = 0; j < (C + 1); ++j) {
      long long x = 4 * i;
      long long y = 4 * j;
      long long val = add + (x * x + y * y) * sum_W + x * fx + y * fy;
      if (val < ans) ans = val, ans_i = i, ans_j = j;
      ans = min(ans, val);
    }
  cout << ans << endl;
  cout << ans_i << " " << ans_j << endl;
  return 0;
}
