/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com5
 * Date: 2013.10.04
 *
 * Status: TL 53, Time > 5.0
 */

import java.util.*;
import java.io.*;
import java.math.*;

public class subset_sk_n2logn_rational_fast {

	BigInteger val(long x) {
		return BigInteger.valueOf(x);
	}

	public class Num implements Comparable<Num> {
		BigInteger a, b;

		Num( long a, long b ) {
			this.a = val(a);
			this.b = val(b);
		}
		Num( BigInteger a, BigInteger b ) {
			this.a = a;
			this.b = b;
		}
		Num norm() {
			BigInteger g = a.gcd(b);
			a = a.divide(g);
			b = b.divide(g);
			if (b.compareTo(BigInteger.ZERO) < 0) {
				a = a.negate();
				b = b.negate();
			}
			return this;
		}
		public int compareTo( Num x ) {
			int f = a.compareTo(x.a);
			return f != 0 ? f : b.compareTo(x.b);
		}
		public Num multiply( long x ) {
			return new Num(a.multiply(val(x)), b);
		}
		public Num divide( Num x ) {
			a = a.multiply(x.b);
			b = b.multiply(x.a);
			return this;
		}
		public Num subtract( Num x ) {
			a = a.multiply(x.b).subtract(b.multiply(x.a));
			b = b.multiply(x.b);
			return this;
		}
	}

	int n, d;

	public class Vec implements Comparable<Vec> {
		Num v[];
		int ind;

		public int compareTo( Vec x ) {
			for (int tmp, i = 0; i < d; i++) {
				if ((tmp = v[i].compareTo(x.v[i])) != 0) {
					return tmp;
				}
			}
			return 0;
		}
	}

	StreamTokenizer in;
	PrintWriter out;
	
	int nextInt() throws IOException {
		in.nextToken();
		return (int)in.nval;
	}

	public void run() throws IOException {
		final String NAME = "subset";
		in = new StreamTokenizer(new BufferedReader(new FileReader(NAME + ".in")));
		PrintWriter out = new PrintWriter(new File(NAME + ".out"));

		n = nextInt();
		d = nextInt();
		
		int a[][] = new int[n][d];
		Num b[] = new Num[d];
		Vec c[] = new Vec[n];
		int cn, pn, p[] = new int[n];
		int rn = 0, rp[] = new int[n];

		for (int i = 0; i < n; i++) {
			c[i] = new Vec();
			c[i].v = new Num[d];
			for (int j = 0; j < d; j++) {
				a[i][j] = nextInt();
			}
		}
		for (int i = 0; i < n; i++) {
			pn = cn = 0;

			int pos = 0;
			while (a[i][pos] == 0) {
				pos++;
			}
			for (int j = 0; j < i; j++) {
				int good = 1;
				for (int k = 0; k < d; k++) {
					b[k] = new Num(a[j][k], 1);
				}
				if (a[j][pos] != 0) {
					Num koef = new Num(a[j][pos], a[i][pos]);
					good = 0;
					for (int k = 0; k < d; k++) {
						if (!b[k].subtract(koef.multiply(a[i][k])).a.equals(BigInteger.ZERO)) {
							good = 1;
						}
					}
				}
				if (good == 0) {
					p[pn++] = j;
				} else {
					int id = 0;
					while (b[id].a.equals(BigInteger.ZERO)) {
						id++;
					}
					Num koef = new Num(b[id].a, b[id].b);
					for (int k = 0; k < d; k++) {
						c[cn].v[k] = b[k].divide(koef).norm();
					}
					c[cn++].ind = j;
				}
			}
			Arrays.sort(c, 0, cn);

			int ma = 0, rj = 0;
			for (int j = 0, k; j < cn; j = k) {
				for (k = j + 1; k < cn && c[j].compareTo(c[k]) == 0; k++)
					;
				if (k - j > ma) {
					ma = k - j;
					rj = j;
				}
			}
			if (ma + pn + 1 > rn) {
				rn = ma + pn + 1;
				for (int j = 0; j < pn; j++) {
					rp[j] = p[j];
				}
				for (int j = 0; j < ma; j++) {
					rp[j + pn] = c[rj + j].ind;
				}
				rp[ma + pn] = i;
			}
		}

		out.println(rn);
		for (int i = 0; i < rn; i++) {
			out.print(rp[i] + 1);
			out.print(i + 1 < rn ? " " : "\n");
		}
		out.close();
	}

	static public void main(String[] args) throws Exception {
		new subset_sk_n2logn_rational_fast().run();
	}
}
