#include <bits/stdc++.h>
using namespace std;
bool operator<(const complex<double>& a, const complex<double>& b) {
  return abs(a) < abs(b);
}
int w, h;
int64_t c[1000][1000];
double ysum[1000];
double xsum[1000];
int main() {
  cin >> h >> w;
  int64_t m_x, m_y;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> c[x][y];
    }
  }
  for (int x = 0; x < w; x++) {
    ysum[x] = 0;
    for (int y = 0; y < h; y++) {
      ysum[x] += c[x][y];
    }
  }
  int64_t min = 9223372036854775807LL;
  for (int x = 0; x < w; x++) {
    int64_t sum = 0;
    for (int xpos = 0; xpos < w; xpos++) {
      sum +=
          abs(ysum[xpos] * (4 * xpos - (4 * x - 2)) * (4 * xpos - (4 * x - 2)));
    }
    if (min > sum) {
      min = sum;
      m_x = x;
    }
  }
  for (int y = 0; y < h; y++) {
    xsum[y] = 0;
    for (int x = 0; x < w; x++) {
      xsum[y] += c[x][y];
    }
  }
  int yval = -1;
  min = 9223372036854775807LL;
  for (int y = 0; y < h; y++) {
    int64_t sum = 0;
    for (int ypos = 0; ypos < h; ypos++) {
      sum += xsum[ypos] * (4 * ypos - (4 * y - 2)) * (4 * ypos - (4 * y - 2));
    }
    if (min > sum) {
      min = sum;
      m_y = y;
    }
  }
  int64_t sum = 0;
  for (int x = 0; x < w; x++)
    for (int y = 0; y < h; y++) {
      sum += c[x][y] * ((4 * x - (4 * m_x - 2)) * (4 * x - (4 * m_x - 2)) +
                        (4 * y - (4 * m_y - 2)) * (4 * y - (4 * m_y - 2)));
    }
  cout << sum << endl;
  cout << m_y << " " << m_x << endl;
}
