#include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
long long r;
bool comp(vector<long long> a, vector<long long> b) {
  long long mxa, mxb;
  mxa = a[r] - a[a.size() - 1];
  mxb = b[r] - b[b.size() - 1];
  return mxa < mxb;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(m, vector<long long>(n));
  map<vector<long long>, vector<long long>> make_pair;
  vector<vector<long long>> ans(n);
  for (long long i = 0; i < m; ++i) {
    for (long long j = 0; j < n; ++j) cin >> v[i][j];
    make_pair[v[i]].push_back(i + 1);
  }
  long long sum = 0;
  for (long long i = 0; i < m; ++i) sum += v[i][n - 1];
  long long out = -1;
  long long mn = INT_MAX;
  for (long long i = 0; i < n - 1; ++i) {
    vector<vector<long long>> c(m, vector<long long>(n));
    for (long long j = 0; j < m; ++j) {
      for (long long k = 0; k < n; ++k) c[j][k] = v[j][k];
    }
    r = i;
    sort(c.begin(), c.end(), comp);
    long long s1 = 0, s2 = sum;
    for (long long j = 0; j < m; ++j) {
      s1 += v[j][i];
    }
    long long idx = 0;
    while (s1 < s2) {
      s1 -= c[idx][i];
      s2 -= c[idx][n - 1];
      long long t = 0;
      while (count(ans[i].begin(), ans[i].end(), make_pair[c[idx]][t])) {
        t++;
      }
      ans[i].push_back(make_pair[c[idx]][t]);
      idx++;
    }
    if (ans[i].size() < mn) {
      out = i;
      mn = ans[i].size();
    }
  }
  cout << ans[out].size() << "\n";
  for (auto &j : ans[out]) cout << j << " ";
}
