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

struct A {
    int next = -1;
    int move = int.max;
}

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;
            }
        }
    }

    A[][] dp = new A[][](N, D);
    foreach (i; 0 .. N) {
        dp[i][D - 1] = A(-1, (g[i][D - 1] ? 0 : int.max));
    }

    foreach_reverse (j; 0 .. D - 1) {
        foreach (i; 0 .. N) {
            if (!g[i][j]) continue;
            foreach (k; 0 .. N ) {
                if (!g[k][j + 1]) continue;
                if (i == k) {
                    if (dp[i][j].move > dp[k][j + 1].move) {
                        dp[i][j].move = dp[k][j + 1].move;
                        dp[i][j].next = k;
                    }
                } else {
                    if (dp[i][j].move > dp[k][j + 1].move + 1) {
                        dp[i][j].move = dp[k][j + 1].move + 1;
                        dp[i][j].next = k;
                    }
                }
            }
        }
    }
    //foreach (_; dp) _.map!(a => a.move == int.max ? A(-1, -1) : a).writeln;

    int[] ans;

    A head;
    int headIndex;
    foreach (i; 0 .. N) {
        if (head.move > dp[i][0].move) {
            head = dp[i][0];
            headIndex = i;
        }
    }
    ans ~= headIndex;

    A cur = head;
    int d = 0;
    while (cur.next >= 0) {
        ans ~= cur.next;
        cur = dp[cur.next][++d];
    }

    int M = head.move;
    int P;
    foreach (i; 0 .. ans.length) {
        P += f[ans[i]][i];
    }

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