/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com5
 * Date: 2013.10.04
 *
 * Status: Accepted, Time = 2.8
 */

#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 = 1000;
const int D = 10;

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

  bool operator == ( num x ) { return a * x.b - b * x.a == 0; }
  bool operator != ( num x ) { return a * x.b - b * x.a != 0; }
  bool operator < ( num x ) { return a * x.b - b * x.a < 0; }
  bool operator > ( num x ) { return a * x.b - b * x.a > 0; }

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

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

int bn, cn, id[3], ind[N], o[N];
num b[3][D];
num c[N][D];

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

inline bool vless( int i, int j )
{
  forn(k, d)
    if (c[i][k] != c[j][k])
      return c[i][k] < c[j][k];
  return 0; 
}

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)
  {
    pn = bn = cn = 0;
    add(a[_i]);
    forn(j, _i)
    {
      add(a[j]);
      if (bn == 1)
        p[pn++] = j;
      else
      {
        bn--;
        memcpy(c[cn], b[bn], sizeof(b[0]));
        int pos = 0;
        while (!c[cn][pos])
          pos++;
        num t = c[cn][pos];
        forn(i, d)
          if (!!c[cn][i])
            c[cn][i] /= t;
        o[cn] = cn, ind[cn++] = j;
      }
    }
    sort(o, o + cn, vless);

    int ma = 0, rj = 0;
    for (int j = 0, k; j < cn; j = k)
    {
      for (k = j + 1; k < cn && !vless(o[j], o[k]); k++)
        ;
      if (k - j > ma)
        ma = k - j, rj = j;
    }
    if (ma + pn + 1 > rn)
    {
      rn = ma + pn + 1;
      forn(i, pn)
        rp[i] = p[i];
      forn(i, ma)
        rp[i + pn] = ind[o[rj + i]];
      rp[ma + pn] = _i;
    }
  }
  printf("%d\n", rn);
  forn(i, rn)
    printf("%d%c", rp[i] + 1, " \n"[i == rn - 1]);
  return 0;
}
