import std.stdio;
import std.algorithm;
import std.functional;
import std.string;
import std.array;
import std.conv;

void main() {
    int N, D; readf("%d %d\n", &N, &D);
    int[][] f = new int[][N];
    int[][] g = new int[][](N, D);
    foreach (i; 0 .. N) {
        f[i]  = readln.chomp.split(" ").map!(to!int).array;
    }
    foreach (j; 0 .. D) {
        int mcost = int.max;
        foreach (i; 0 .. N) {
            mcost = min(mcost, f[i][j]);
        }
        foreach (i; 0 .. N) {
            if (f[i][j] == mcost) {
                g[i][j] = 1;
            }
        }
    }

    foreach (i; 0 .. N) {
        foreach_reverse (j; 0 .. D - 1) {
            if (g[i][j] > 0 && g[i][j + 1] > 0) {
                g[i][j] = g[i][j + 1] + 1;
            }
        }
    }

    int[] ans;
    for (int j = 0; j < D; ) {
        int m = 0;
        foreach (i; 0 .. N) {
            m = max(m, g[i][j]);
        }
        foreach (i; 0 .. N) {
            if (g[i][j] == m) {
                foreach (k; 0 .. g[i][j]) {
                    ans ~= i + 1;
                }
                j += g[i][j];
                break;
            }
        }
    }

    int P, M;
    foreach (i; 0 .. ans.length - 1) {
        if (ans[i] != ans[i + 1]) {
            M++;
        }
    }
    foreach (i; 0 .. ans.length) {
        P += f[ans[i] - 1][i];
    }

    writeln(P, " ", M);
    foreach (c; ans) {
        c.writeln;
    }
}