#include<bits/stdc++.h>
using namespace std;

const int INF = 1e9;

int N, D, p[55][55], dp[55][55][55];

signed main(){  
  
  cin>>N>>D;
  
  for(int i=0;i<N;i++)
    for(int j=0;j<D;j++) cin>>p[i][D-j-1];
  
  for(int i=0;i<=D;i++)
    for(int j=0;j<N;j++)
      for(int k=0;k<=D;k++) dp[i][j][k] = INF;
  
  for(int i=0;i<N;i++) dp[1][i][0] = p[i][0];

  
  for(int i=1;i<D;i++){
    
    for(int j=0;j<N;j++){

      for(int k=0;k<=D;k++){
	
	if( dp[i][j][k] == INF ) continue;
	
	for(int l=0;l<N;l++){
	  
	  int nk = k;
	  
	  if( j != l ) nk++;
	  
	  dp[i+1][l][nk] = min( dp[i+1][l][nk], dp[i][j][k] + p[l][i] );
	  
	}
	
      }
      
    }
    
  }
  
  int P = INF;
  
  for(int i=0;i<N;i++)
    for(int j=0;j<=D;j++) P = min( P, dp[D][i][j] );
  
  int M = INF;
  
  for(int i=0;i<N;i++)
    for(int j=0;j<=D;j++)
      if( P == dp[D][i][j] ) M = min( M, j );


  cout<<P<<' '<<M<<endl;

  int h = INF;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<=D;j++)
      
      if( P == dp[D][i][j] && M == j ){
	h = i;
	break;
      }
    
    if( h != INF ) break;
    
  }
  
  vector<int> ans;
  
  int I = D, x = M;

  ans.push_back( h + 1 );
  
  while( --I ){
    
    for(int i=0;i<N;i++){
      
      if( h == i && dp[I+1][h][x] - p[h][I] == dp[I][i][x] ) break;
      
      if( h != i && x != 0 && dp[I+1][h][x] - p[h][I] == dp[I][i][x-1] ){
	h = i;
	x--;
	break;
      }
      
    }
    
    ans.push_back( h + 1 );
  }
  
  for(auto idx : ans ) cout<<idx<<endl;
  
  return 0;
}

