#include <bits/stdc++.h>   using namespace std;   int n, m, tmp;   long long A[1005];   long long B[1005];   long long Acost(int q) {     q *= 4;     long long ret = 0;     for (int i = 1; i <= n; i++) {       long long tmp2 = i * 4 - 2 - q;       ret += A[i] * tmp2 * tmp2;     }     return ret;   }   long long Bcost(int q) {     q *= 4;     long long ret = 0;     for (int i = 1; i <= m; i++) {       long long tmp2 = i * 4 - 2 - q;       ret += B[i] * tmp2 * tmp2;     }     return ret;   }   int ansx, ansy;   long long sumx = LLONG_MAX, sumy = LLONG_MAX;   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 >> tmp;         A[i] += tmp;         B[j] += tmp;       }     }     for (int i = 0; i <= n; i++) {       long long tmp3 = Acost(i);       if (tmp3 < sumx) {         ansx = i;         sumx = tmp3;       }     }     for (int i = 0; i <= m; i++) {       long long tmp3 = Bcost(i);       if (tmp3 < sumy) {         ansy = i;         sumy = tmp3;       }     }     cout << sumx + sumy << endl;     cout << ansx <<     << ansy << endl;   }   