/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com5
 * Date: 2013.09.29
 */

#include <cstdio>
#include <cassert>
#include <cstring>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

const int N = 100;
const int D = 10;

int n, d, a[N][D], is[N][N][N];
int k, p[N];      
int rn, rp[N];

void go( int i )
{
  if (i == n)
  {
    if (k >= rn)
      rn = k, memcpy(rp, p, sizeof(p));
    return;
  }

  int bad = 0;
  forn(a, k)
    forn(b, a)
      if (!is[p[a]][p[b]][i])
        a = b = k, bad = 1;
  if (!bad)
    p[k++] = i, go(i + 1), k--;
  go(i + 1);
}

struct num
{
  ll a, b;

  num() { }
  num( ll a, ll b ) : a(a), b(b) { norm(); }

  void norm()
  {
    ll g = __gcd(a, b);
    assert(b);
    a /= g, b /= g;
    if (b < 0)
      a = -a, b = -b;
  }

  num operator + ( num x ) { return num(a * x.b + b * x.a, x.b * b); }
  num operator - ( num x ) { return num(a * x.b - b * x.a, x.b * b); }
  num operator * ( num x ) { return num(a * x.a, b * x.b); }
  num operator / ( num x ) { return num(a * x.b, b * x.a); }
  num operator ~ () { return num(b, a); }
  bool operator ! () { return a == 0; }

  #define DECLARE(s) \
    num& operator s##= ( num x ) { return *this = (*this s x); }
  DECLARE(+)
  DECLARE(-)
  DECLARE(*)
  DECLARE(/)
};

int bn, id[3];
num b[3][D];

void add( int *a )
{
  forn(i, d)
    b[bn][i] = num(a[i], 1);
  forn(i, bn)
    if (!!b[bn][id[i]])
    {
      num koef = b[bn][id[i]] / b[i][id[i]];
      forn(j, d)
        b[bn][j] -= koef * b[i][j];
    }
  forn(i, d)
    if (!!b[bn][i])
      id[bn++] = i, i = d;
}

int main()
{
  #define NAME "subset"
  assert(freopen(NAME ".in", "r", stdin));
  assert(freopen(NAME ".out", "w", stdout));

  assert(scanf("%d%d", &n, &d) == 2 && n <= N && d <= D);
  forn(i, n)
    forn(j, d)
      assert(scanf("%d", &a[i][j]) == 1);
  forn(i, n)
    forn(j, n)
      forn(k, n)
      {
        bn = 0;
        add(a[i]);
        add(a[j]);
        add(a[k]);
        is[i][j][k] = (bn <= 2);
      }
  go(0);      
  printf("%d\n", rn);
  forn(i, rn)
    printf("%d%c", rp[i] + 1, " \n"[i == rn - 1]);
  return 0;
}
