#include <cstdio>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cassert>

using std::vector;
using std::cerr;

typedef vector<int> Vector;
typedef long long ll;

struct Rational {
  ll x_, y_;

  Rational(ll x, ll y) : x_(x), y_(y) {
    assert(y != 0);
    norm();
  }
  Rational(ll x) : Rational(x, 1) {}
  Rational() : Rational(0) {}

  Rational operator-() const {
    return Rational(-x_, y_);
  }
  Rational operator+(const Rational &o) const {
    return Rational(x_ * o.y_ + y_ * o.x_, y_ * o.y_);
  }
  Rational operator-(const Rational &o) const {
    return this->operator+(-o);
  }
  Rational operator*(const Rational &o) const {
    return Rational(x_ * o.x_, y_ * o.y_);
  }
  Rational operator/(const Rational &o) const {
    assert(o != 0);
    return Rational(x_ * o.y_, y_ * o.x_);
  }
  bool operator==(const ll x) const {
    return y_ == 1 && x_ == x;
  }
  bool operator!=(const ll x) const {
    return !this->operator==(x);
  }

 private:
  void norm() {
    ll d = std::__gcd(x_, y_);
    x_ /= d;
    y_ /= d;
    if (y_ < 0) {
      x_ = -x_;
      y_ = -y_;
    }
    
  }
};

namespace std{
  ostream &operator<<(ostream &os, const Rational &r) {
    os << r.x_;
    if (r.y_ != 1)
      os << "/" << r.y_;
    return os;
  }
}

template <size_t n>
void Gauss(Rational mat[n][n + 1], Rational res[n]) {

  for (size_t q = 0; q < n; ++q) {
    for (size_t i = 0; i < n; ++i) {
      if ((mat[i][i] == 0 || i >= q) && mat[i][q] != 0) {
        std::swap(mat[q], mat[i]);
        break;
      }
    }
    if (mat[q][q] == 0)
      continue;

    for (size_t i = q + 1; i < n; ++i) {
      if (mat[i][q] == 0) continue;

      Rational m = mat[i][q] / mat[q][q];

      for (size_t j = q; j < n + 1; ++j) {
        mat[i][j] = mat[i][j] - mat[q][j] * m;
      }
    }
  }

  if (mat[n - 1][n - 1] != 0)
    return;

  res[n - 1] = 1;
  for (size_t j = n - 2; j >= 0; --j) {
    for (int i = j; i >= 0; --i) {
      mat[i][n] = mat[i][n] - mat[i][j + 1] * res[j + 1];
    }
    
    if (mat[j][j] == 0)
      res[j] = 1;
    else
      res[j] = mat[j][n] / mat[j][j];
  }

}

bool LieWithin(const Vector &x, const Vector &y, const Vector &z) {
  Rational mat[3][4];
  Rational res[3];
  for (size_t i = 0; i < 3; ++i) {
    res[i] = 0;
    for (size_t j = 0; j < 4; ++j)
      mat[i][j] = 0;
  }

  for (size_t d = 0; d < 3 && d < x.size(); ++d) {
    mat[d][0] = x[d];
    mat[d][1] = y[d];
    mat[d][2] = z[d];
  }

  Gauss<3>(mat, res);

  if (res[0] == 0 && res[1] == 0 && res[2] == 0)
    return false;

  for (size_t d = 0; d < x.size(); ++d) {
    if (res[0] * x[d] + res[1] * y[d] + res[2] * z[d] != 0) {
      assert(d >= 3);
      return false;
    }
  }
  return true;
}

Vector ReadVector(const size_t n, std::ifstream &in) {
  Vector res(n);
  for (size_t i = 0; i < n; ++i) {
    in >> res[i];
  }
  return res;
}


int main(int /* argc */, const char **/* argv[] */)
{
  std::ifstream in("subset.in");
  std::ofstream out("subset.out");

  size_t n, d;
  in >> n >> d;

  vector<Vector> all_vectors;
  for (size_t i = 0; i < n; ++i) {
    all_vectors.push_back(ReadVector(d, in));
  }

  vector<size_t> best_ans;
  for (const auto &x : all_vectors) {
    for (const auto &y : all_vectors) {
      vector<size_t> cur_ans;

      size_t id = 0;
      for (const auto &z : all_vectors) {
        ++id;
        if (LieWithin(x, y, z))
          cur_ans.push_back(id);
      }

      if (cur_ans.size() > best_ans.size())
        best_ans = std::move(cur_ans);
    }
  }

  out << best_ans.size() << "\n";
  for (const auto &id : best_ans)
    out << id << " ";

  in.close();
  out.close();

  return 0;
}
