#include <bits/stdc++.h>
using namespace std;
const long long N = 1100;
long long n, m, c[N][N];
inline long long sgn(double x) { return x < -1e-8 ? -1 : (x < 1e-8 ? 0 : 1); }
inline double sqr(double x) { return x * x; }
struct point {
  double x, y;
  inline void scan() { scanf("%lf%lf", &x, &y); }
  inline void print() { printf("(%lf %lf)\n", x, y); }
};
point operator+(point a, point b) {
  a.x += b.x;
  a.y += b.y;
  return a;
}
point operator-(point a, point b) {
  a.x -= b.x;
  a.y -= b.y;
  return a;
}
point operator*(point a, double b) {
  a.x *= b;
  a.y *= b;
  return a;
}
point operator/(point a, double b) {
  a.x /= b;
  a.y /= b;
  return a;
}
bool operator<(point a, point b) {
  return (sgn(a.x - b.x) == -1 ||
          (sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == -1));
}
inline double dot(point a, point b) { return a.x * b.x + a.y * b.y; }
inline double crs(point a, point b) { return a.x * b.y - a.y * b.x; }
inline double dis(point a, point b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
struct line {
  point v, t;
  inline point getpoint(double k) { return v + t * k; }
  inline void rotate(double Cos, double Sin) {
    double x = t.x * Cos - t.y * Sin, y = t.x * Sin + t.y * Cos;
    t = (point){x, y};
  }
  inline void unit() {
    double tmp = dis(t, (point){0, 0});
    t.x /= tmp;
    t.y /= tmp;
  }
};
inline long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
inline long long solve(long long x, long long y) {
  x *= 4;
  y *= 4;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      long long tx = 2 + 4 * (i - 1), ty = 2 + 4 * (j - 1);
      ans += c[i][j] * ((x - tx) * (x - tx) + (y - ty) * (y - ty));
    }
  }
  return ans;
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) c[i][j] = read();
  point now = (point){0, 0};
  double sum = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++)
      if (c[i][j]) {
        point tmp = (point){4.0 * (i - 1) + 2, 4.0 * (j - 1) + 2};
        line a = (line){now, tmp - now};
        a.unit();
        double x = (dis(tmp, now) * c[i][j]) / (sum + c[i][j]);
        now = a.v + a.t * x;
        sum += c[i][j];
      }
  }
  long long ax, ay, ans = 0x3f3f3f3f3f3f3f3f;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      long long x = 4 * i, y = 4 * j;
      if (sgn(now.x - x) <= 0 && sgn(now.y - y) <= 0 &&
          sgn(now.x - x + 4) >= 0 && sgn(now.y - y + 4) >= 0) {
        for (long long a = -1; a <= 0; a++) {
          for (long long b = -1; b <= 0; b++) {
            long long now = solve(i + a, j + b);
            if (now < ans) {
              ans = now;
              ax = i + a;
              ay = j + b;
            }
          }
        }
        break;
      }
    }
  }
  printf("%lld\n%lld %lld\n", ans, ax, ay);
}
