inf = open("disease.in", "r")
ouf = open("disease.out", "w")

n, m = map(int, inf.readline().split())
has = [False] * n
non = [False] * n

a = [[int(x) for x in inf.readline().split()] for i in range(m)]
for i in range(m):
	if a[i][n] == 0:
		for j in range(n):
			if a[i][j] == 1:
				non[j] = True

bad = False
for i in range(m):
	if a[i][n] == 1:
		cnt = 0
		last = 0
		for j in range(n):
			if a[i][j] == 1 and not non[j]:
				cnt += 1
				last = j
		if cnt == 1:
			has[last] = True
		if cnt == 0:
			bad = True

if bad:
	print("Incorrect", file=ouf)
else:
	bad = [i + 1 for i in range(n) if non[i]]
	print(str(len(bad)) + " " + " ".join([str(x) for x in bad]), file=ouf)
	good = [i + 1 for i in range(n) if has[i]]
	print(str(len(good)) + " " + " ".join([str(x) for x in good]), file=ouf)
	other = [i + 1 for i in range(n) if not has[i] and not non[i]]
	print(str(len(other)) + " " + " ".join([str(x) for x in other]), file=ouf)
