m = [[1, 9, 2, 8, 6, 1],
[8, 1, 11, 7, 6, 4],
[10, 12, 1, 9, 12, 14],
[8, 10, 3, 5, 17, 8],
[6, 4, 10, 13, 16, 19]]
mm = [[0] * (len(m[0]) + 1)]
for row in m:
r, t = [0], 0
for i, x in enumerate(row, 1):
t += x & 1
r.append(t + mm[-1][i])
mm.append(r)
res = []
for bottom in range(len(mm)):
for right in range(len(mm[0])):
for top in range(bottom):
for left in range(right - 1, -1, -1):
s = mm[bottom][right] + mm[top][left] - \
mm[top][right] - mm[bottom][left]
if s == (bottom - top) * (right - left):
res.append((s, top, left, bottom, right))
else:
break
s, top, left, bottom, right = max(res)
print("%d\n%d %d\n%d %d" % (s, top, left, bottom - 1, right - 1))
for row in m[top:bottom]:
print(row[left:right])