#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using vpi = vector<pair<long long, long long>>;
using pi = pair<long long, long long>;
const long long nax = 1e5 + 7;
const long long mod = 1e9 + 7;
const long long inf = numeric_limits<long long>::max() - (long long)9e6;
long long n, m;
vector<pair<vi, long long>> vec;
void test() {
  cin >> n;
  cin >> m;
  vec.resize(m);
  for (long long j = 0; j < m; j++) {
    vec[j].first.resize(n);
    for (long long i = 0; i < n; i++) {
      cin >> vec[j].first[i];
    }
    vec[j].second = j;
  }
  vector<long long> ans(m);
  iota((ans).begin(), (ans).end(), 0);
  for (long long win = 0; win < n - 1; win++) {
    vi here;
    sort((vec).begin(), (vec).end(),
         [&](const pair<vi, long long> &a, const pair<vi, long long> &b) {
           long long d1 = a.first[win] - a.first.back();
           long long d2 = b.first[win] - b.first.back();
           return d1 > d2;
         });
    long long score1 = 0, score2 = 0;
    for (long long i = 0; i < m; i++) {
      score1 += vec[i].first[win];
      score2 += vec[i].first.back();
    }
    for (long long i = m - 1; i >= 0; i--) {
      if (score1 >= score2) break;
      here.push_back(vec[i].second);
      score1 -= vec[i].first[win];
      score2 -= vec[i].first.back();
    }
    if (((long long)(ans).size()) > ((long long)(here).size())) ans = here;
  }
  cout << ((long long)(ans).size()) << '\n';
  for (long long x : ans) cout << x + 1 << ' ';
}
signed main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  long long T = 1;
  while (T--) {
    test();
    cout << "\n";
  }
  return 0;
}
