AtCoder Beginner Contest 109 - Make Them Even

There is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).
In Cell (i, j), a_{ij} coins are placed.
You can perform the following operation any number of times:
Operation: Choose a cell that was not chosen before and contains one or more coins, then move one of those coins to a vertically or horizontally adjacent cell.
Maximize the number of cells containing an even number of coins.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq H, W \leq 500
 - 0 \leq a_{ij} \leq 9

-----Input-----
Input is given from Standard Input in the following format:
H W
a_{11} a_{12} ... a_{1W}
a_{21} a_{22} ... a_{2W}
:
a_{H1} a_{H2} ... a_{HW}

-----Output-----
Print a sequence of operations that maximizes the number of cells containing an even number of coins, in the following format:
N
y_1 x_1 y_1' x_1'
y_2 x_2 y_2' x_2'
:
y_N x_N y_N' x_N'

That is, in the first line, print an integer N between 0 and H \times W (inclusive), representing the number of operations.
In the (i+1)-th line (1 \leq i \leq N), print four integers y_i, x_i, y_i' and x_i' (1 \leq y_i, y_i' \leq H and 1 \leq x_i, x_i' \leq W), representing the i-th operation. These four integers represents the operation of moving one of the coins placed in Cell (y_i, x_i) to a vertically or horizontally adjacent cell, (y_i', x_i').
Note that if the specified operation violates the specification in the problem statement or the output format is invalid, it will result in Wrong Answer.

-----Sample Input-----
2 3
1 2 3
0 1 1

-----Sample Output-----
3
2 2 2 3
1 1 1 2
1 3 1 2

Every cell contains an even number of coins after the following sequence of operations:
 - Move the coin in Cell (2, 2) to Cell (2, 3).
 - Move the coin in Cell (1, 1) to Cell (1, 2).
 - Move one of the coins in Cell (1, 3) to Cell (1, 2).

Source: atcoder | Difficulty: MEDIUM


Solutions:
(h, w) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(h)]
count = 0
ans = []
for i in range(h):
	for j in range(w - 1):
		if l[i][j] % 2 == 1:
			l[i][j + 1] += 1
			ans.append([i + 1, j + 1, i + 1, j + 2])
			count += 1
for i in range(h - 1):
	if l[i][w - 1] % 2 == 1:
		count += 1
		l[i + 1][w - 1] += 1
		ans.append([i + 1, w, i + 2, w])
print(count)
for i in ans:
	print(*i)


(h, w) = map(int, input().split())
a = []
for i in range(h):
	b = [int(i) % 2 for i in input().split()]
	a.append(b)
c = []
odd = 0
n = 0
while n < h:
	if odd == 0:
		for i in range(w):
			c.append([n, i])
		odd = 1
	elif odd == 1:
		for i in range(w - 1, -1, -1):
			c.append([n, i])
		odd = 0
	n += 1
ans = []
for i in range(len(c)):
	if a[c[i][0]][c[i][1]] == 1:
		if i == len(c) - 1:
			break
		ans.append([str(c[i][0] + 1), str(c[i][1] + 1), str(c[i + 1][0] + 1), str(c[i + 1][1] + 1)])
		a[c[i + 1][0]][c[i + 1][1]] += 1
print(len(ans))
for i in range(len(ans)):
	print(' '.join(ans[i]))


(h, w) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
ans = []
for i in range(h):
	for j in range(w):
		if A[i][j] % 2 == 1:
			if j != w - 1:
				A[i][j + 1] += 1
				ans.append((i + 1, j + 1, i + 1, j + 2))
			elif i != h - 1:
				A[i + 1][j] += 1
				ans.append((i + 1, j + 1, i + 2, j + 1))
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


(h, w) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
B = []
for i in range(h):
	flag = 1 if i % 2 == 0 else -1
	for j in range(w)[::flag]:
		if A[i][j] % 2 == 1:
			if 0 <= j + flag < w:
				B.append([i, j, i, j + flag])
				A[i][j + flag] += 1
			elif i + 1 < h:
				B.append([i, j, i + 1, j])
				A[i + 1][j] += 1
print(len(B))
for i in B:
	print(*list(map(lambda x: x + 1, i)))


(H, W) = map(int, input().split())
M = [list(map(int, input().split())) for i in range(H)]
LIST = []
for i in range(H):
	for j in range(W - 1):
		if M[i][j] % 2 == 1:
			LIST.append((i + 1, j + 1, i + 1, j + 2))
			M[i][j] -= 1
			M[i][j + 1] += 1
for i in range(H - 1):
	if M[i][W - 1] % 2 == 1:
		LIST.append((i + 1, W, i + 2, W))
		M[i][W - 1] -= 1
		M[i + 1][W - 1] += 1
print(len(LIST))
for i in LIST:
	print(i[0], i[1], i[2], i[3])


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
N = 0
Q = []
for w in range(W):
	for h in range(H - 1):
		if A[h][w] % 2 == 1:
			A[h][w] -= 1
			A[h + 1][w] += 1
			Q.append([h + 1, w + 1, h + 2, w + 1])
			N += 1
for w in range(W - 1):
	if A[H - 1][w] % 2 == 1:
		A[H - 1][w] -= 1
		A[H - 1][w + 1] += 1
		Q.append([H, w + 1, H, w + 2])
		N += 1
print(N)
for i in range(N):
	print(' '.join(map(str, Q[i])))


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
ans = []
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2 == 1:
			a[i][j + 1] += 1
			ans.append(str(i + 1) + ' ' + str(j + 1) + ' ' + str(i + 1) + ' ' + str(j + 2))
for i in range(H - 1):
	if a[i][W - 1] % 2 == 1:
		a[i + 1][W - 1] += 1
		ans.append(str(i + 1) + ' ' + str(W) + ' ' + str(i + 2) + ' ' + str(W))
n = len(ans)
print(n)
for i in range(n):
	print(ans[i])


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
op = []
for j in range(w):
	for i in range(h - 1):
		if a[i][j] % 2 == 1:
			a[i][j] -= 1
			a[i + 1][j] += 1
			op.append((i, j, i + 1, j))
for j in range(w - 1):
	if a[h - 1][j] % 2 == 1:
		a[h - 1][j] -= 1
		a[h - 1][j + 1] += 1
		op.append((h - 1, j, h - 1, j + 1))
print(len(op))
for (y1, x1, y2, x2) in op:
	print(y1 + 1, x1 + 1, y2 + 1, x2 + 1)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
ans = []
for h in range(H - 1):
	for w in range(W - 1):
		if a[h][w] % 2 == 1:
			ans.append([h + 1, w + 1, h + 1, w + 2])
			a[h][w + 1] += 1
	if a[h][-1] % 2 == 1:
		ans.append([h + 1, W, h + 2, W])
		a[h + 1][-1] += 1
for w in range(W - 1):
	if a[H - 1][w] % 2 == 1:
		ans.append([H, w + 1, H, w + 2])
		a[H - 1][w + 1] += 1
print(len(ans))
for an in ans:
	print(*an)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
ans = []
for i in range(H):
	for j in range(W):
		if a[i][j] % 2:
			if i + 1 < H:
				a[i][j] -= 1
				a[i + 1][j] += 1
				ans.append((i + 1, j + 1, i + 2, j + 1))
			elif j + 1 < W:
				a[i][j] -= 1
				a[i][j + 1] += 1
				ans.append((i + 1, j + 1, i + 1, j + 2))
print(len(ans))
for x in ans:
	print(*x)


(h, w) = map(int, input().split())
coin = [list(map(int, input().split())) for i in range(h)]
ans = []
c = 0
for i in range(h):
	for j in range(w - 1):
		if coin[i][j] % 2:
			coin[i][j + 1] += 1
			ans.append([i + 1, j + 1, i + 1, j + 2])
			c += 1
for k in range(h - 1):
	if coin[k][w - 1] % 2:
		coin[k + 1][w - 1] += 1
		ans.append([k + 1, w, k + 2, w])
		c += 1
print(c)
for i in range(c):
	print(ans[i][0], ans[i][1], ans[i][2], ans[i][3])


(h, w) = map(int, input().split())
M = []
for i in range(h):
	M.append(list(map(int, input().split())))
ANS = []
cnt = 0
for i in range(h):
	for j in range(w):
		if M[i][j] % 2 == 1:
			for (x, y) in [(0, 1), (1, 0)]:
				if (0 <= i + x and i + x < h) and (0 <= j + y and j + y < w):
					M[i + x][j + y] += 1
					cnt += 1
					ANS.append([i + 1, j + 1, x + i + 1, y + j + 1])
					break
print(cnt)
for i in range(cnt):
	print(*ANS[i])


import sys
sys.setrecursionlimit(10 ** 8)

def Z():
	return int(input())

def ZZ():
	return [int(_) for _ in input().split()]

def main():
	(H, W) = ZZ()
	A = [ZZ() for _ in range(H)]
	done = [[False] * W for _ in range(H)]
	path = []
	operation = []
	for i in range(H):
		if i % 2:
			for j in range(W)[::-1]:
				path.append([i, j])
		else:
			for j in range(W):
				path.append([i, j])
	for i in range(H * W - 1):
		(x, y) = path[i]
		(nx, ny) = path[i + 1]
		if A[x][y] % 2:
			operation.append([x, y, nx, ny])
			A[x][y] -= 1
			A[nx][ny] += 1
	print(len(operation))
	for (i, j, k, l) in operation:
		print((i + 1, j + 1, k + 1, l + 1))
	return

def __starting_point():
	main()
__starting_point()


(H, W) = map(int, input().split())
a = [[] for i in range(0, H)]
for i in range(0, H):
	a[i] = list(map(int, input().split()))
ans = []
for i in range(0, H):
	for j in range(0, W - 1):
		if a[i][j] % 2 == 1:
			ans.append((i, j, i, j + 1))
			a[i][j + 1] += 1
for i in range(0, H - 1):
	if a[i][W - 1] % 2 == 1:
		ans.append((i, W - 1, i + 1, W - 1))
		a[i + 1][W - 1] += 1
N = len(ans)
print(N)
for i in range(0, N):
	(x, y, z, w) = ans[i]
	print(x + 1, y + 1, z + 1, w + 1)


def solve():
	(t, *a) = open(0)
	(h, w) = map(int, t.split())
	a = [[int(x) % 2 for x in y.split()] for y in a]
	ret = []
	for i in range(h):
		for j in range(w - 1):
			if a[i][j]:
				a[i][j + 1] ^= 1
				ret += [i + 1, j + 1, i + 1, j + 2]
	for i in range(h - 1):
		if a[i][-1]:
			a[i + 1][-1] ^= 1
			ret += [i + 1, w, i + 2, w]
	print(len(ret) // 4)
	for (a, b, c, d) in zip(*[iter(ret)] * 4):
		print(a, b, c, d)
solve()


(h, w) = map(int, input().split())
A = []
for i in range(h):
	A.append([int(i) for i in input().split()])
Ans = []
for i in range(h):
	for j in range(w - 1):
		if A[i][j] % 2 == 1:
			Ans.append([i + 1, j + 1, i + 1, j + 2])
			A[i][j + 1] += 1
for i in range(h - 1):
	if A[i][w - 1] % 2 == 1:
		Ans.append([i + 1, w, i + 2, w])
		A[i + 1][w - 1] += 1
print(len(Ans))
for ans in Ans:
	print(*ans)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
yx = []
for i in range(H * W):
	y = i // W
	x = W - i % W - 1 if y % 2 else i % W
	yx.append((y, x))
ans = []
for i in range(H * W - 1):
	(y, x) = yx[i]
	if a[y][x] % 2:
		(yd, xd) = yx[i + 1]
		a[y][x] -= 1
		a[yd][xd] += 1
		ans.append((y + 1, x + 1, yd + 1, xd + 1))
n = len(ans)
print(n)
for i in range(n):
	print(*ans[i])


(H, W) = map(int, input().split())
A = []
for _ in range(H):
	a = list(map(int, input().split()))
	A.append(a)
ans = []
for i in range(H):
	for j in range(W - 1):
		if A[i][j] % 2 == 1:
			A[i][j + 1] += 1
			ans += [[i + 1, j + 1, i + 1, j + 2]]
for i in range(H - 1):
	if A[i][W - 1] % 2 == 1:
		A[i + 1][W - 1] += 1
		ans += [[i + 1, W, i + 2, W]]
print(len(ans))
for a in ans:
	print(' '.join(map(str, a)))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
ans = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			ans.append([i + 1, j + 1, i + 1, j + 2])
			a[i][j + 1] += 1
	if i != h - 1 and a[i][w - 1] % 2 == 1:
		ans.append((i + 1, w, i + 2, w))
		a[i + 1][w - 1] += 1
print(len(ans))
for i in range(len(ans)):
	print(' '.join(map(str, ans[i])))


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
results = []
for y in range(H):
	for x in range(W - 1):
		if A[y][x] % 2 == 1:
			A[y][x] -= 1
			A[y][x + 1] += 1
			results.append((y + 1, x + 1, y + 1, x + 2))
	if y != H - 1 and A[y][W - 1] % 2 == 1:
		A[y][W - 1] -= 1
		A[y + 1][W - 1] += 1
		results.append((y + 1, W, y + 2, W))
print(len(results))
for r in results:
	print(*r)


(H, W) = list(map(int, input().split()))
grid = []
for _ in range(H):
	line = list(map(int, input().split()))
	grid.append(line)
q = []
for i in range(H):
	if i % 2 == 0:
		for j in range(W):
			q.append([i, j])
	else:
		for j in range(W - 1, -1, -1):
			q.append([i, j])
cnt = 0
op_list = []
for i in range(len(q) - 1):
	if grid[q[i][0]][q[i][1]] % 2 == 0:
		pass
	else:
		grid[q[i][0]][q[i][1]] -= 1
		grid[q[i + 1][0]][q[i + 1][1]] += 1
		cnt += 1
		op_list.append([q[i][0], q[i][1], q[i + 1][0], q[i + 1][1]])
print(cnt)
for op in op_list:
	print((op[0] + 1, op[1] + 1, op[2] + 1, op[3] + 1))


(H, W) = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(H)]
ope = []
for y in range(H):
	for x in range(W):
		if grid[y][x] % 2 != 0 and (y, x) != (H - 1, W - 1):
			grid[y + (W == x + 1)][x + (W != x + 1)] += 1
			ope.append((y + 1, x + 1, y + 1 + (W == x + 1), x + 1 + (W != x + 1)))
print(len(ope))
for o in ope:
	print(*o)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
l = []
for i in range(h):
	for j in range(w):
		if a[i][j] % 2:
			if i + 1 < h:
				a[i][j] -= 1
				a[i + 1][j] += 1
				l.append((i + 1, j + 1, i + 2, j + 1))
			elif j + 1 < w:
				a[i][j] -= 1
				a[i][j + 1] += 1
				l.append((i + 1, j + 1, i + 1, j + 2))
print(len(l))
for i in l:
	print(*i)


(H, W) = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(H)]
result = []
y = 0
while y < H:
	x = 0
	while x < W:
		if a[y][x] % 2 == 1:
			if x == W - 1:
				if y == H - 1:
					break
				else:
					result.append('%d %d %d %d' % (y + 1, x + 1, y + 2, x + 1))
					a[y + 1][x] += 1
			else:
				result.append('%d %d %d %d' % (y + 1, x + 1, y + 1, x + 2))
				a[y][x + 1] += 1
		x += 1
	if y == H - 1:
		break
	y += 1
	x = W - 1
	while x >= 0:
		if a[y][x] % 2 == 1:
			if x == 0:
				if y == H - 1:
					break
				else:
					result.append('%d %d %d %d' % (y + 1, x + 1, y + 2, x + 1))
					a[y + 1][x] += 1
			else:
				result.append('%d %d %d %d' % (y + 1, x + 1, y + 1, x))
				a[y][x - 1] += 1
		x -= 1
	y += 1
print(len(result))
print('\n'.join(result))


(H, W) = map(int, input().split())
a = []
for h in range(H):
	a.append(list(map(int, input().split())))
ans = []
for h in range(H):
	for w in range(W - 1):
		if a[h][w] & 1:
			a[h][w] -= 1
			a[h][w + 1] += 1
			ans.append([h + 1, w + 1, h + 1, w + 2])
for h in range(H - 1):
	if a[h][W - 1] & 1:
		a[h][W - 1] -= 1
		a[h + 1][W - 1] += 1
		ans.append([h + 1, W, h + 2, W])
print(len(ans))
for s in ans:
	print('{} {} {} {}'.format(*s))


(H, W) = map(int, input().split())
B = []
C = []
for h in range(H):
	A = list(map(int, input().split()))
	w = 0
	for w in range(1, W):
		if A[w - 1] % 2:
			C.append((h + 1, w, h + 1, w + 1))
			A[w] += 1
	B.append(A[w])
	if h and B[-2] % 2:
		C.append((h, W, h + 1, W))
		B[h] += 1
print(len(C))
for c in C:
	print(*c)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
A = []
for y in range(H):
	for x in range(W):
		if y % 2 == 0:
			A.append([y, x, a[y][x]])
		else:
			A.append([y, W - 1 - x, a[y][W - 1 - x]])
OUTPUT = []
for i in range(H * W - 1):
	if A[i][2] % 2 == 1:
		OUTPUT.append((A[i][0] + 1, A[i][1] + 1, A[i + 1][0] + 1, A[i + 1][1] + 1))
		A[i + 1][2] += 1
print(len(OUTPUT))
for out in OUTPUT:
	print(*out)


(h, w) = map(int, input().split())
aa = [list(map(int, input().split())) for _ in range(h)]
ans = []
for hi in range(h):
	for wi in range(w - 1):
		if aa[hi][wi] % 2 == 1:
			aa[hi][wi] -= 1
			aa[hi][wi + 1] += 1
			ans.append([hi + 1, wi + 1, hi + 1, wi + 2])
	if hi < h - 1:
		if aa[hi][-1] % 2 == 1:
			aa[hi][-1] -= 1
			aa[hi + 1][-1] += 1
			ans.append([hi + 1, w, hi + 2, w])
print(len(ans))
for (yp, xp, yn, xn) in ans:
	print('{} {} {} {}'.format(yp, xp, yn, xn))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
for i in range(h):
	a[i] = [aij % 2 for aij in a[i]]
(cnt, ans) = (0, [])
for (i, ai) in enumerate(a):
	for j in range(w):
		if i % 2 == 1:
			j = w - 1 - j
		if cnt == 1:
			ans.append([bi + 1, bj + 1, i + 1, j + 1])
			ai[j] = ai[j] + 1
		cnt = int(ai[j] == 1)
		(bi, bj) = (i, j)
print(len(ans))
for q in ans:
	print(*q)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
ans = []
for i in range(h - 1):
	for j in range(w):
		if a[i][j] % 2 == 1:
			a[i + 1][j] += 1
			ans.append([i + 1, j + 1, i + 2, j + 1])
for i in range(w - 1):
	if a[h - 1][i] % 2 == 1:
		a[h - 1][i + 1] += 1
		ans.append([h, i + 1, h, i + 2])
print(len(ans))
for m in ans:
	print(*m)


(h, w) = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(h)]
B = []
count = 0
for i in range(h):
	for j in range(w - 1):
		if A[i][j] % 2 == 1:
			A[i][j + 1] += 1
			B.append([i + 1, j + 1, i + 1, j + 2])
			count += 1
for i in range(h - 1):
	if A[i][-1] % 2 == 1:
		A[i + 1][-1] += 1
		B.append([i + 1, w, i + 2, w])
		count += 1
print(count)
for i in B:
	print(i[0], i[1], i[2], i[3])


(h, w) = map(int, input().split())
mod2 = lambda x: int(x) % 2
a = [list(map(mod2, input().split())) for _ in range(h)]
(cnt, ans, rvs) = (0, [], -1)
for (i, ai) in enumerate(a):
	rvs *= -1
	for j in range(w)[::rvs]:
		if cnt == 1:
			ans.append([bi + 1, bj + 1, i + 1, j + 1])
			ai[j] += 1
		cnt = int(ai[j] == 1)
		(bi, bj) = (i, j)
print(len(ans))
for q in ans:
	print(*q)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for h in range(H)]
x = 1
w = 0
ans = []
for h in range(H):
	while 0 <= w + x < W:
		if A[h][w] % 2 == 1:
			ans.append([h + 1, w + 1, h + 1, w + x + 1])
			A[h][w + x] += 1
		w += x
	if A[h][w] % 2 == 1 and h + 1 < H:
		ans.append([h + 1, w + 1, h + 1 + 1, w + 1])
		A[h + 1][w] += 1
	x *= -1
print(len(ans))
for _ in ans:
	print(*_)


(h, w) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(h)]
ct = 0
ans = []
for i in range(h):
	for j in range(w - 1):
		if l[i][j] % 2 == 1:
			ans.append([i + 1, j + 1, i + 1, j + 2])
			ct += 1
			l[i][j + 1] += 1
for k in range(h - 1):
	if l[k][w - 1] % 2 == 1:
		ans.append([k + 1, w, k + 2, w])
		ct += 1
		l[k + 1][w - 1] += 1
print(ct)
for i in range(ct):
	print(ans[i][0], ans[i][1], ans[i][2], ans[i][3])


(h, w) = map(int, input().split())
a = []
for i in range(h):
	ai = list(map(int, input().split()))
	a.append(ai)
ans = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			ans.append([i + 1, j + 1, i + 1, j + 2])
			a[i][j + 1] += 1
for i in range(h - 1):
	if a[i][-1] % 2 == 1:
		ans.append([i + 1, w, i + 2, w])
		a[i + 1][-1] += 1
print(len(ans))
for (i, j, k, l) in ans:
	print(i, j, k, l)


import sys
(H, W, *A) = map(int, sys.stdin.read().split())
ans = []
n = 0
ans_append = ans.append
for i in range(H * W - 1):
	if i % W == W - 1:
		continue
	if A[i] % 2:
		A[i + 1] += 1
		n += 1
		ans_append(map(str, (i // W + 1, i % W + 1, (i + 1) // W + 1, (i + 1) % W + 1)))
for i in range(W - 1, W * H - 1, W):
	if A[i] % 2:
		A[i + W] += 1
		n += 1
		ans_append(map(str, (i // W + 1, i % W + 1, i // W + 2, i % W + 1)))
print(n)
print('\n'.join((' '.join(row) for row in ans)))


(H, W) = map(int, input().split())
a = [0] * H
for i in range(H):
	a[i] = list(map(int, input().split()))
ans = []
for y in range(H):
	for x in range(W - 1):
		if a[y][x] % 2 == 1:
			a[y][x] -= 1
			a[y][x + 1] += 1
			ans.append([y + 1, x + 1, y + 1, x + 2])
for i in range(H - 1):
	if a[i][-1] % 2 == 1:
		a[i][-1] -= 1
		a[i + 1][-1] += 1
		ans.append([i + 1, W, i + 2, W])
print(len(ans))
for i in ans:
	print(*i)


(H, W) = (int(i) for i in input().split())
a = [[int(i) for i in input().split()] for i in range(H)]
ans = []
ans_list = []
for h in range(H):
	for w in range(W):
		if w != W - 1:
			if a[h][w] % 2 == 1:
				a[h][w + 1] += 1
				ans.append([h + 1, w + 1, h + 1, w + 2])
		elif a[h][w] % 2 == 1 and h != H - 1:
			a[h + 1][w] += 1
			ans.append([h + 1, w + 1, h + 2, w + 1])
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
out = []
n = 0
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2 == 1:
			n += 1
			a[i][j] -= 1
			a[i][j + 1] += 1
			out.append([i + 1, j + 1, i + 1, j + 2])
for i in range(H - 1):
	if a[i][-1] % 2 == 1:
		n += 1
		a[i][-1] -= 1
		a[i + 1][-1] += 1
		out.append([i + 1, W, i + 2, W])
print(n)
for i in range(n):
	print(' '.join(map(str, out[i])))


(h, w) = map(int, input().split())
a = []
for _ in range(h):
	a.append(list(map(int, input().split())))
res = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			a[i][j + 1] += 1
			res.append(str(i + 1) + ' ' + str(j + 1) + ' ' + str(i + 1) + ' ' + str(j + 2))
for i in range(h - 1):
	if a[i][w - 1] % 2 == 1:
		a[i + 1][w - 1] += 1
		res.append(str(i + 1) + ' ' + str(w) + ' ' + str(i + 2) + ' ' + str(w))
print(len(res))
print('\n'.join(res))


(h, w) = map(int, input().split())
flag = False
ans = []
for i in range(h):
	A = list(map(int, input().split()))
	if i % 2 == 0:
		r = range(w)
	else:
		r = range(w - 1, -1, -1)
	for j in r:
		a = A[j]
		if (i > 0 or j > 0) and flag:
			ans.append(f'{prev_i + 1} {prev_j + 1} {i + 1} {j + 1}')
		if flag:
			if a % 2 == 0:
				flag = True
			else:
				flag = False
		elif a % 2 == 0:
			flag = False
		else:
			flag = True
		prev_i = i
		prev_j = j
print(len(ans))
print('\n'.join(ans))


(h, w) = map(int, input().split())
b = [list(map(int, input().split())) for i in range(h)]
c = []
for i in range(h):
	if i % 2:
		b[i] = b[i][::-1]
for i in range(h):
	for j in range(w):
		if b[i][j] % 2 == 0:
			continue
		y = yy = i
		x = xx = j
		if j == w - 1:
			yy += 1
			xx = 0
		else:
			xx += 1
		if not (yy < h and xx < w):
			continue
		b[yy][xx] += 1
		if yy % 2:
			xx = w - 1 - xx
		if y % 2:
			x = w - 1 - x
		c.append([y + 1, x + 1, yy + 1, xx + 1])
print(len(c))
for i in c:
	print(*i)


(h, w) = (int(i) for i in input().split())
a = [[int(i) for i in input().split()] for i in range(h)]
ans = []
for i in range(h - 1):
	for j in range(w):
		if a[i][j] % 2:
			ans.append([i + 1, j + 1, i + 2, j + 1])
			a[i + 1][j] += 1
for j in range(w - 1):
	if a[h - 1][j] % 2:
		ans.append([h, j + 1, h, j + 2])
		a[h - 1][j + 1] += 1
print(len(ans))
for (i, j, i2, j2) in ans:
	print(i, j, i2, j2)


(h, w) = map(int, input().split())
d = [list(map(int, input().split())) for i in range(h)]
l = []
for i in range(h):
	if i % 2 == 0:
		for j in range(w):
			l.append([i, j])
	else:
		for j in range(w - 1, -1, -1):
			l.append([i, j])
m = 0
x = []
for i in range(len(l) - 1):
	if d[l[i][0]][l[i][1]] % 2 == 1:
		d[l[i][0]][l[i][1]] -= 1
		d[l[i + 1][0]][l[i + 1][1]] += 1
		x.append(i)
		m += 1
print(m)
for i in x:
	print(l[i][0] + 1, l[i][1] + 1, l[i + 1][0] + 1, l[i + 1][1] + 1)


(h, w) = map(int, input().split())
hw = [[]]
ans = []
for i in range(h):
	ht = [0] + list(map(int, input().split()))
	hw.append(ht)
for i in range(1, h + 1):
	for j in range(1, w):
		if hw[i][j] % 2 == 1:
			ans.append([i, j, i, j + 1])
			hw[i][j + 1] += 1
for k in range(1, h):
	if hw[k][-1] % 2 == 1:
		ans.append([k, w, k + 1, w])
		hw[k + 1][-1] += 1
print(len(ans))
for i in ans:
	for j in range(len(i)):
		i[j] = str(i[j])
	print(' '.join(i))


def main():
	(H, W) = map(int, input().split())
	field = []
	for _ in range(H):
		line = list(map(int, input().split()))
		field.append(line)
	ans = []
	for i in range(H):
		if i % 2 == 0:
			for j in range(W):
				if field[i][j] % 2 == 1:
					field[i][j] -= 1
					if j != W - 1:
						field[i][j + 1] += 1
						ans.append((i + 1, j + 1, i + 1, j + 2))
					elif i != H - 1:
						field[i + 1][j] += 1
						ans.append((i + 1, j + 1, i + 2, j + 1))
					else:
						field[i][j] += 1
		else:
			for j in range(W - 1, -1, -1):
				if field[i][j] % 2 == 1:
					field[i][j] -= 1
					if j != 0:
						field[i][j - 1] += 1
						ans.append((i + 1, j + 1, i + 1, j))
					elif i != H - 1:
						field[i + 1][j] += 1
						ans.append((i + 1, j + 1, i + 2, j + 1))
					else:
						field[i][j] += 1
	print(len(ans))
	for line in ans:
		print(*line, sep=' ')

def __starting_point():
	main()
__starting_point()


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
res = []
for i in range(H - 1):
	for j in range(W):
		if a[i][j] % 2 != 0:
			a[i + 1][j] += 1
			res.append((i + 1, j + 1, i + 2, j + 1))
for i in range(W - 1):
	if a[-1][i] % 2 != 0:
		a[-1][i + 1] += 1
		res.append((H, i + 1, H, i + 2))
print(len(res))
for (a, b, c, d) in res:
	print(a, b, c, d)


(H, W) = map(int, input().split())
S = []
for i in range(H):
	a = [int(x) for x in input().split()]
	S.append(a)
Ans = []
for i in range(H):
	for j in range(W):
		if S[i][j] % 2 == 1:
			if j + 1 < W:
				S[i][j] -= 1
				S[i][j + 1] += 1
				Ans.append((i + 1, j + 1, i + 1, j + 2))
			elif i + 1 < H:
				S[i][j] -= 1
				S[i + 1][j] += 1
				Ans.append((i + 1, j + 1, i + 2, j + 1))
			else:
				continue
print(len(Ans))
for i in range(len(Ans)):
	print(*list(Ans[i]))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
ans = []

def operate(i, j, k, l):
	a[i][j] -= 1
	a[k][l] += 1
	ans.append([i + 1, j + 1, k + 1, l + 1])
for j in range(0, w):
	for i in range(0, h - 1):
		if a[i][j] % 2 == 1:
			operate(i, j, i + 1, j)
for j in range(0, w - 1):
	if a[h - 1][j] % 2 == 1:
		operate(h - 1, j, h - 1, j + 1)
print(len(ans))
for i in ans:
	print(i[0], i[1], i[2], i[3])


def main():
	(H, W) = map(int, input().split())
	A = [list(map(int, input().split())) for _ in range(H)]
	WL = list(range(W))
	WLR = WL[::-1]
	path = []
	for h in range(H):
		if h % 2 == 0:
			for w in WL:
				path.append((h, w))
		else:
			for w in WLR:
				path.append((h, w))
	ret = []
	for i in range(H * W - 1):
		(h, w) = path[i]
		if A[h][w] % 2 == 1:
			ret.append(i)
			(hn, wn) = path[i + 1]
			A[hn][wn] += 1
	print(len(ret))
	for i in ret:
		(h, w) = path[i]
		(nh, nw) = path[i + 1]
		print(h + 1, w + 1, nh + 1, nw + 1)

def __starting_point():
	main()
__starting_point()


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
mr = []
md = []
for h in range(H):
	for w in range(W):
		if a[h][w] % 2 != 0 and w < W - 1:
			mr.append((h, w))
			a[h][w + 1] += 1
	if a[h][w] % 2 != 0 and h < H - 1:
		md.append((h, w))
		a[h + 1][w] += 1
print(len(mr) + len(md))
for i in range(len(mr)):
	print(mr[i][0] + 1, mr[i][1] + 1, mr[i][0] + 1, mr[i][1] + 2)
for i in range(len(md)):
	print(md[i][0] + 1, md[i][1] + 1, md[i][0] + 2, md[i][1] + 1)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
N = 0
ans = []
for x in range(W):
	for y in range(H - 1):
		if a[y][x] % 2 == 1:
			a[y][x] -= 1
			a[y + 1][x] += 1
			ans.append([y + 1, x + 1, y + 2, x + 1])
			N += 1
for x in range(W - 1):
	if a[H - 1][x] % 2 == 1:
		a[H - 1][x] -= 1
		a[H - 1][x + 1] += 1
		ans.append([H, x + 1, H, x + 2])
		N += 1
print(N)
for i in ans:
	print(' '.join(map(str, i)))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
i = 0
j = 0
k = 0
l = 0
ans = []
n = 1
while n < h * w:
	k += 2 * ((j + 1) % 2) - 1
	if k == w or k == -1:
		k -= (k + abs(k)) // k - 1
		l += 1
	if a[j][i] % 2 == 1:
		a[l][k] += 1
		ans.append([j + 1, i + 1, l + 1, k + 1])
	i = k
	j = l
	n += 1
print(len(ans))
for i in ans:
	for j in range(3):
		print(i[j], end=' ')
	print(i[-1])


((h, w), *a) = [map(int, o.split()) for o in open(0)]
B = []
l = []
for y in range(h):
	(*A,) = a[y]
	for x in range(1, w):
		c = A[x - 1] % 2
		l += [(y + 1, x, y + 1, x + 1)] * c
		A[x] += c
	B += (A[w - 1],)
	if y and B[-2] % 2:
		l += ((y, w, y + 1, w),)
		B[y] += 1
print(len(l))
for a in l:
	print(*a)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
n = 0
ans = []
b = []
for i in range(h):
	for j in range(w):
		b.append((i, j if i % 2 == 0 else w - j - 1))
for i in range(h * w - 1):
	(y, x) = b[i]
	if a[y][x] % 2 == 0:
		continue
	a[y][x] -= 1
	n += 1
	(ny, nx) = b[i + 1]
	a[ny][nx] += 1
	ans.append('{} {} {} {}'.format(str(y + 1), str(x + 1), str(ny + 1), str(nx + 1)))
print(n)
print('\n'.join(ans))


(t, *a) = open(0)
(h, w) = map(int, t.split())
a = [list(map(int, x.split())) for x in a]
ret = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2:
			a[i][j + 1] += 1
			ret += [' '.join(map(str, [i + 1, j + 1, i + 1, j + 2]))]
for i in range(h - 1):
	if a[i][-1] % 2:
		a[i + 1][-1] += 1
		ret += [' '.join(map(str, [i + 1, w, i + 2, w]))]
print(len(ret), *ret, sep='\n')


(h, w) = list(map(int, input().split()))
a = [list(map(lambda x: int(x) & 1, input().split())) for i in range(h)]
ans = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] & 1 == 1:
			ans.append(' '.join([str(i + 1), str(j + 1), str(i + 1), str(j + 2)]))
			a[i][j + 1] += 1
for i in range(h - 1):
	if a[i][-1] & 1 == 1:
		ans.append(' '.join([str(i + 1), str(w), str(i + 2), str(w)]))
		a[i + 1][-1] += 1
print(len(ans))
for s in ans:
	print(s)


import itertools
(h, w) = map(int, input().split())
L = [[[i, j] for j in range(w)][::(-1) ** i] for i in range(h)]
L = list(itertools.chain(*L))
A = [list(map(int, input().split())) for _ in range(h)]
ans = 0
Q = []
for i in range(h * w - 1):
	(nh, nw) = L[i]
	if A[nh][nw] % 2:
		(nnh, nnw) = (L[i + 1][0], L[i + 1][1])
		A[nnh][nnw] += 1
		Q.append([nh + 1, nw + 1, nnh + 1, nnw + 1])
		ans += 1
print(ans)
for i in Q:
	print(*i, sep=' ')


(h, w) = map(int, input().split())
grid = []
for i in range(h):
	grid.append(list(map(int, input().split())))
ans = []
for i in range(h):
	for j in range(w):
		if j == w - 1:
			if grid[i][j] % 2 == 1 and i != h - 1:
				grid[i + 1][j] += 1
				ans.append([i + 1, j + 1, i + 2, j + 1])
		elif grid[i][j] % 2 == 1:
			grid[i][j + 1] += 1
			ans.append([i + 1, j + 1, i + 1, j + 2])
print(len(ans))
for i in range(len(ans)):
	print(*ans[i])


def i1():
	return int(input())

def i2():
	return [int(i) for i in input().split()]
[h, w] = i2()
a = []
for i in range(h):
	a.append(i2())
z = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			a[i][j + 1] += 1
			z.append([i + 1, j + 1, i + 1, j + 2])
for i in range(h - 1):
	if a[i][w - 1] % 2 == 1:
		a[i + 1][w - 1] += 1
		z.append([i + 1, w, i + 2, w])
print(len(z))
for (i, j, k, l) in z:
	print(i, j, k, l)


import itertools
(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
s = []
for (i, j) in itertools.product(range(h), range(w - 1)):
	if a[i][j] % 2 == 1:
		s.append((i + 1, j + 1, i + 1, j + 2))
		a[i][j] -= 1
		a[i][j + 1] += 1
for i in range(h - 1):
	if a[i][w - 1] % 2 == 1:
		s.append((i + 1, w, i + 2, w))
		a[i][w - 1] -= 1
		a[i + 1][w - 1] += 1
print(len(s))
for l in s:
	print(*l)


(H, W) = map(int, input().split())
a = []
for i in range(H):
	a.append(list(map(int, input().split())))
move = []
for i in range(H):
	for j in range(W):
		if a[i][j] % 2 == 1:
			if j < W - 1:
				move.append([i, j, i, j + 1])
				a[i][j + 1] += 1
			elif i < H - 1:
				move.append([i, j, i + 1, j])
				a[i + 1][j] += 1
print(len(move))
for (x, y, x2, y2) in move:
	print(x + 1, y + 1, x2 + 1, y2 + 1)


(H, W) = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
answer = []

def to_move(y, x, y_, x_):
	if A[y - 1][x - 1] % 2:
		answer.append((y, x, y_, x_))
		A[y - 1][x - 1] -= 1
		A[y_ - 1][x_ - 1] += 1
for h in range(1, H + 1):
	for w in range(1, W):
		to_move(h, w, h, w + 1)
for h in range(1, H):
	to_move(h, W, h + 1, W)
print(len(answer))
for a in answer:
	print(' '.join([str(x) for x in a]))


(H, W) = map(int, input().split())
M = [[c % 2 == 1 for c in map(int, input().split())] for i in range(H)]
LIST = []
for i in range(H):
	for j in range(W):
		if M[i][j]:
			if j < W - 1:
				LIST.append((i + 1, j + 1, i + 1, j + 2))
				M[i][j + 1] ^= True
			elif i < H - 1:
				LIST.append((i + 1, j + 1, i + 2, j + 1))
				M[i + 1][j] ^= True
print(len(LIST))
for c in LIST:
	print(*c)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = []
i = j = 0
while i < H:
	if i % 2 == 0:
		if 0 <= j < W - 1:
			if A[i][j] % 2:
				ans.append([i + 1, j + 1, i + 1, j + 2])
				A[i][j + 1] += 1
			j += 1
		else:
			i += 1
			if i < H:
				if A[i - 1][j] % 2:
					ans.append([i, j + 1, i + 1, j + 1])
					A[i][j] += 1
	elif 0 < j:
		if A[i][j] % 2:
			ans.append([i + 1, j + 1, i + 1, j])
			A[i][j - 1] += 1
		j -= 1
	else:
		i += 1
		if i < H:
			if A[i - 1][j] % 2:
				ans.append([i, j + 1, i + 1, j + 1])
				A[i][j] += 1
print(len(ans))
for (a, b, c, d) in ans:
	print(a, b, c, d)


(H, W) = map(int, input().split())
A = []
for i in range(H):
	r = list(map(int, input().split()))
	if i & 1:
		r.reverse()
	A.append(r)
ans = []
for i in range(H * W - 1):
	if A[i // W][i % W] & 1:
		j = i + 1
		A[j // W][j % W] += 1
		ans.append([i, j])

def f(n):
	x = n // W
	y = n % W
	if x & 1:
		y = W - y - 1
	return f'{x + 1} {y + 1}'
print(len(ans))
for (a, b) in ans:
	print(f(a), f(b))


(h, w) = map(int, input().split())
a = [''] * h
b = [''] * (h * w)
cnt = 0
for i in range(h):
	a[i] = list(map(int, input().split()))
for j in range(h):
	for k in range(w - 1):
		if a[j][k] % 2 == 1:
			a[j][k] -= 1
			a[j][k + 1] += 1
			b[cnt] = str(j + 1) + ' ' + str(k + 1) + ' ' + str(j + 1) + ' ' + str(k + 2)
			cnt += 1
for l in range(h - 1):
	if a[l][w - 1] % 2 == 1:
		a[l][w - 1] -= 1
		a[l + 1][w - 1] += 1
		b[cnt] = str(l + 1) + ' ' + str(w) + ' ' + str(l + 2) + ' ' + str(w)
		cnt += 1
print(cnt)
for m in range(cnt):
	print(b[m])


(h, w) = map(int, input().split())
a = []
for _ in range(h):
	a.append(list(map(int, input().split())))
ans = []
cnt = 0
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			a[i][j + 1] += 1
			a[i][j] -= 1
			cnt += 1
			ans.append((i + 1, j + 1, i + 1, j + 2))
for i in range(h - 1):
	if a[i][w - 1] % 2 == 1:
		a[i][w - 1] -= 1
		a[i + 1][w - 1] += 1
		cnt += 1
		ans.append((i + 1, w, i + 2, w))
print(cnt)
for (i, j, k, l) in ans:
	print(i, j, k, l)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Ans = []
for y in range(H):
	for x in range(W - 1):
		if A[y][x] % 2:
			A[y][x + 1] += 1
			Ans.append('{} {} {} {}'.format(y + 1, x + 1, y + 1, x + 2))
x = W - 1
for y in range(H - 1):
	if A[y][x] % 2:
		A[y + 1][x] += 1
		Ans.append('{} {} {} {}'.format(y + 1, x + 1, y + 2, x + 1))
N = len(Ans)
print(N)
if N > 0:
	print('\n'.join(Ans))


(H, W) = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(H)]
N = 0
A = []
for h in range(H):
	if h % 2 == 0:
		for w in range(W):
			if grid[h][w] % 2:
				if w != W - 1:
					grid[h][w] -= 1
					grid[h][w + 1] += 1
					A.append([h + 1, w + 1, h + 1, w + 2])
					N += 1
				else:
					if h == H - 1:
						continue
					grid[h][w] -= 1
					grid[h + 1][w] += 1
					A.append([h + 1, w + 1, h + 2, w + 1])
					N += 1
	else:
		for w in range(W - 1, -1, -1):
			if grid[h][w] % 2:
				if w != 0:
					grid[h][w] -= 1
					grid[h][w - 1] += 1
					A.append([h + 1, w + 1, h + 1, w])
					N += 1
				else:
					if h == H - 1:
						continue
					grid[h][w] -= 1
					grid[h + 1][w] += 1
					A.append([h + 1, w + 1, h + 2, w + 1])
					N += 1
print(N)
for a in A:
	print(' '.join(map(str, a)))


(h, w) = map(int, input().split())
grid = [[i & 1 for i in map(int, input().split())] for _ in range(h)]
ans = []
for i in range(h - 1):
	for j in range(w):
		if grid[i][j] % 2 == 0:
			continue
		grid[i + 1][j] += 1
		ans.append((i + 1, j + 1, i + 2, j + 1))
for i in range(w - 1):
	if grid[-1][i] % 2 == 0:
		continue
	grid[-1][i + 1] += 1
	ans.append((h, i + 1, h, i + 2))
print(len(ans))
for i in ans:
	print(*i, sep=' ')


(h, w) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(h)]
p = True
q = [0, 0]
d = []
for i in range(h):
	for j in range((w - 1) * (i % 2), -1 if i % 2 == 1 else w, -1 if i % 2 == 1 else 1):
		if p:
			if s[i][j] % 2 == 1:
				q = [i, j]
				p = False
		else:
			d.append([q[0] + 1, q[1] + 1, i + 1, j + 1])
			q = [i, j]
			if s[i][j] % 2 == 1:
				p = True
print(len(d))
for i in d:
	print(i[0], i[1], i[2], i[3])


(h, w) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(h)]
m = []
for y in range(h):
	for x in range(w):
		if x < w - 1 and l[y][x] % 2:
			l[y][x] -= 1
			l[y][x + 1] += 1
			m.extend([[y + 1, x + 1, y + 1, x + 2]])
for x in range(w):
	for y in range(h):
		if y < h - 1 and l[y][x] % 2:
			l[y][x] -= 1
			l[y + 1][x] += 1
			m.extend([[y + 1, x + 1, y + 2, x + 1]])
print(len(m))
for i in m:
	print(*i, sep=' ')


(H, W) = map(int, input().split())
a = [[int(i) for i in input().split()] for _ in range(H)]
op = []
for y in range(H - 1):
	for x in range(W):
		if a[y][x] % 2 != 0:
			op.append((y + 1, x + 1, y + 2, x + 1))
			a[y + 1][x] += 1
for x in range(W - 1):
	if a[H - 1][x] % 2 != 0:
		op.append((H, x + 1, H, x + 2))
		a[H - 1][x + 1] += 1
print(len(op))
for op_ in op:
	print(*op_)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
ans = []
for i in range(H - 1):
	S = A[i]
	T = A[i + 1]
	for j in range(W):
		if S[j] % 2:
			ans.append('%d %d %d %d' % (i + 1, j + 1, i + 2, j + 1))
			S[j] -= 1
			T[j] += 1
S = A[-1]
for j in range(W - 1):
	if S[j] % 2:
		ans.append('%d %d %d %d' % (H, j + 1, H, j + 2))
		S[j] -= 1
		S[j + 1] += 1
print(len(ans))
print(*ans, sep='\n')


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
n = 0
memo = []
for x in range(W):
	for y in range(H - 1):
		if A[y][x] % 2 == 1:
			A[y][x] -= 1
			A[y + 1][x] += 1
			n += 1
			memo.append([y + 1, x + 1, y + 2, x + 1])
for x in range(W - 1):
	if A[H - 1][x] % 2 == 1:
		A[H - 1][x] -= 1
		A[H - 1][x + 1] += 1
		memo.append([H, x + 1, H, x + 2])
		n += 1
print(n)
for i in range(n):
	print(' '.join(map(str, memo[i])))


(H, W) = map(int, input().split())
src = [list(map(int, input().split())) for i in range(H)]
order = []
for i in range(H):
	if i % 2 == 0:
		for j in range(W):
			order.append((i, j))
	else:
		for j in reversed(range(W)):
			order.append((i, j))
ans = []
for ((y1, x1), (y2, x2)) in zip(order, order[1:]):
	if src[y1][x1] % 2:
		ans.append((y1 + 1, x1 + 1, y2 + 1, x2 + 1))
		src[y2][x2] += 1
print(len(ans))
for row in ans:
	print(*row)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
l = []
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2 == 0:
			continue
		l.append((i + 1, j + 1, i + 1, j + 2))
		a[i][j] -= 1
		a[i][j + 1] += 1
for i in range(H - 1):
	if a[i][W - 1] % 2 == 0:
		continue
	l.append((i + 1, W, i + 2, W))
	a[i][W - 1] -= 1
	a[i + 1][W - 1] += 1
print(len(l))
for (y, x, y_, x_) in l:
	print('{} {} {} {}'.format(y, x, y_, x_))


(H, W) = map(int, input().split())
grid = [None] * H
for i in range(H):
	grid[i] = list(map(int, input().split()))
ans = []
for i in range(H):
	for j in range(W):
		if grid[i][j] % 2 == 1:
			if j + 1 < W:
				grid[i][j] -= 1
				grid[i][j + 1] += 1
				ans.append([i + 1, j + 1, i + 1, j + 1 + 1])
			elif i + 1 < H:
				grid[i][j] -= 1
				grid[i + 1][j] += 1
				ans.append([i + 1, j + 1, i + 1 + 1, j + 1])
			else:
				continue
print(len(ans))
for p in ans:
	print(*p)


(H, W) = map(int, input().split())
a = [[int(i) for i in input().split()] for i in range(H)]
ans = []
for i in range(H - 1):
	for j in range(W):
		if a[i][j] % 2 == 1:
			ans.append((i, j, i + 1, j))
			a[i][j] -= 1
			a[i + 1][j] += 1
for j in range(W - 1):
	if a[H - 1][j] % 2 == 1:
		ans.append((H - 1, j, H - 1, j + 1))
		a[H - 1][j] -= 1
		a[H - 1][j + 1] += 1
print(len(ans))
for i in ans:
	print(i[0] + 1, i[1] + 1, i[2] + 1, i[3] + 1)


import sys
sr = lambda : sys.stdin.readline().rstrip()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
(H, W) = lr()
A = [lr() for _ in range(H)]
answer = []
for i in range(H):
	for j in range(W - 1):
		if A[i][j] & 1:
			answer.append((i + 1, j + 1, i + 1, j + 2))
			A[i][j + 1] += 1
for i in range(H - 1):
	if A[i][-1] & 1:
		answer.append((i + 1, W, i + 2, W))
		A[i + 1][-1] += 1
print(len(answer))
for a in answer:
	print(*a)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = []
for h in range(H):
	for w in range(W):
		if A[h][w] % 2 == 1:
			if w == W - 1:
				if h != H - 1:
					B.append((h, w, h + 1, w))
					A[h + 1][w] += 1
			else:
				B.append((h, w, h, w + 1))
				A[h][w + 1] += 1
print(len(B))
for b in B:
	print(' '.join([str(q + 1) for q in b]))


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
B = []
flag = False
for y in range(H):
	if y % 2 == 0:
		w = range(W)
	else:
		w = reversed(range(W))
	for x in w:
		if flag:
			B.append([by + 1, bx + 1, y + 1, x + 1])
		if A[y][x] % 2 == 1:
			flag = not flag
		by = y
		bx = x
print(len(B))
for (a, b, c, d) in B:
	print(a, b, c, d)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
ans = []
for i in range(n):
	for j in range(m - 1):
		if l[i][j] % 2 == 1:
			ans.append([str(i + 1), str(j + 1), str(i + 1), str(j + 2)])
			l[i][j] = 2
			l[i][j + 1] += 1
for i in range(n - 1):
	if l[i][-1] % 2 == 1:
		ans.append([str(i + 1), str(m), str(i + 2), str(m)])
		l[i][-1] = 2
		l[i + 1][-1] += 1
print(len(ans))
for i in range(len(ans)):
	print(' '.join(ans[i]))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
move = []
for i in range(h):
	for j in range(w):
		if a[i][j] % 2 == 1:
			if j + 1 < w:
				a[i][j + 1] += 1
				move.append((i, j, i, j + 1))
			elif i + 1 < h:
				a[i + 1][j] += 1
				move.append((i, j, i + 1, j))
print(len(move))
for (x, y, xp, yp) in move:
	print(x + 1, y + 1, xp + 1, yp + 1)


def myfun(c):
	return c[0]
(h, w) = map(int, input().split())
arr = []
ans = []
for i in range(h):
	temp = list(map(int, input().split()))
	arr.append(temp)
count = 0
for i in range(h):
	for j in range(w):
		if arr[i][j] % 2 == 1:
			if j < w - 1:
				count += 1
				ans.append([i + 1, j + 1, i + 1, j + 2])
				arr[i][j + 1] += 1
				arr[i][j] -= 1
			elif i < h - 1:
				count += 1
				ans.append([i + 1, j + 1, i + 2, j + 1])
				arr[i][j] -= 1
				arr[i + 1][j] += 1
print(count)
for i in range(count):
	print(*ans[i])


import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = 10 ** 18
eps = 10 ** (-7)
(H, W) = list(map(int, readline().split()))
a = [list(map(int, readline().split())) for i in range(H)]
ans = []
for i in range(H - 1):
	if i % 2:
		for j in range(W - 1, 0, -1):
			if a[i][j] % 2:
				ans.append((i + 1, j + 1, i + 1, j))
				a[i][j] -= 1
				a[i][j - 1] += 1
		if a[i][0] % 2:
			ans.append((i + 1, 1, i + 2, 1))
			a[i][0] -= 1
			a[i + 1][0] += 1
	else:
		for j in range(W - 1):
			if a[i][j] % 2:
				ans.append((i + 1, j + 1, i + 1, j + 2))
				a[i][j] -= 1
				a[i][j + 1] += 1
		if a[i][W - 1] % 2:
			ans.append((i + 1, W, i + 2, W))
			a[i][W - 1] -= 1
			a[i + 1][W - 1] += 1
if (H - 1) % 2:
	for j in range(W - 1, 0, -1):
		if a[H - 1][j] % 2:
			ans.append((H, j + 1, H, j))
			a[H - 1][j] -= 1
			a[H - 1][j - 1] += 1
else:
	for j in range(W - 1):
		if a[H - 1][j] % 2:
			ans.append((H, j + 1, H, j + 2))
			a[H - 1][j] -= 1
			a[H - 1][j + 1] += 1
print(len(ans))
for (x, y, u, v) in ans:
	print((x, y, u, v))


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
cnt = 0
path = []
for h in range(H):
	for w in range(W - 1):
		if A[h][w] % 2:
			A[h][w + 1] += 1
			cnt += 1
			path.append((h + 1, w + 1, h + 1, w + 2))
for h in range(H - 1):
	if A[h][-1] % 2:
		A[h + 1][-1] += 1
		cnt += 1
		path.append((h + 1, W, h + 2, W))
print(cnt)
for p in path:
	print(*p)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
ans = []
for r in range(H):
	for c in range(W - 1):
		if a[r][c] % 2 == 1:
			a[r][c + 1] += 1
			ans.append((r, c, r, c + 1))
for r in range(H - 1):
	if a[r][W - 1] % 2 == 1:
		a[r + 1][W - 1] += 1
		ans.append((r, W - 1, r + 1, W - 1))
print(len(ans))
for aa in ans:
	print(*map(lambda x: x + 1, aa))


(H, W) = map(int, input().split())
M = [list(map(int, input().split())) for _ in range(H)]
s = []
for i in range(H):
	for j in range(W - 1):
		if M[i][j] & 1:
			s.append('{} {} {} {}'.format(i + 1, j + 1, i + 1, j + 2))
			M[i][j + 1] += 1
for i in range(H - 1):
	if M[i][W - 1] & 1:
		s.append('{} {} {} {}'.format(i + 1, W, i + 2, W))
		M[i + 1][W - 1] += 1
print(len(s))
print('\n'.join(s))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
l = []
for i in range(h):
	if i % 2 == 0:
		for j in range(w):
			l.append((i, j))
	else:
		for j in range(w)[::-1]:
			l.append((i, j))
ans = []
for i in range(len(l) - 1):
	if a[l[i][0]][l[i][1]] % 2 == 1:
		ans.append([l[i][0] + 1, l[i][1] + 1, l[i + 1][0] + 1, l[i + 1][1] + 1])
		a[l[i][0]][l[i][1]] -= 1
		a[l[i + 1][0]][l[i + 1][1]] += 1
print(len(ans))
for i in ans:
	print(*i)


(H, W) = [int(x) for x in str(input()).split()]
A = []
for i in range(H):
	A.append([int(x) for x in str(input()).split()])
ANS = []
count = 0
for i in range(H):
	for j in range(W - 1):
		if A[i][j] % 2 == 1:
			count += 1
			A[i][j + 1] += 1
			ANS.append(str(i + 1) + ' ' + str(j + 1) + ' ' + str(i + 1) + ' ' + str(j + 2))
for i in range(H - 1):
	if A[i][-1] % 2 == 1:
		count += 1
		A[i + 1][-1] += 1
		ANS.append(str(i + 1) + ' ' + str(W) + ' ' + str(i + 2) + ' ' + str(W))
print(count)
for i in ANS:
	print(i)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
ANSLIST = []
for i in range(H):
	for j in range(W - 1):
		if A[i][j] % 2 == 1:
			ANSLIST.append((i, j, i, j + 1))
			A[i][j] -= 1
			A[i][j + 1] += 1
for i in range(H - 1):
	if A[i][W - 1] % 2 == 1:
		ANSLIST.append((i, W - 1, i + 1, W - 1))
		A[i][W - 1] -= 1
		A[i + 1][W - 1] += 1
print(len(ANSLIST))
for (x, y, z, w) in ANSLIST:
	print(x + 1, y + 1, z + 1, w + 1)


a = int(input().split()[0])
alle = []
counter = 0
output = []
for i in range(a):
	p = input().split()
	p = [int(j) % 2 for j in p]
	for j in range(len(p) - 1):
		if p[j] % 2 == 1:
			output.append([i + 1, j + 1, i + 1, j + 2])
			counter += 1
			p[j + 1] += 1
	alle.append(p[-1])
for i in range(a - 1):
	if alle[i] % 2 == 1:
		output.append([i + 1, len(p), i + 2, len(p)])
		counter += 1
		alle[i + 1] += 1
print(counter)
for i in output:
	print(i[0], i[1], i[2], i[3])


(H, W) = list(map(int, input().split()))
a = [0] * H
for i in range(H):
	if i % 2 == 0:
		a[i] = list(map(int, input().split()))
	else:
		a[i] = list(map(int, input().split()))[::-1]
s = [[0] * W for i in range(H)]
s[0][0] = a[0][0] % 2
for i in range(1, W):
	s[0][i] = (s[0][i - 1] + a[0][i]) % 2
for i in range(1, H):
	for j in range(W):
		if j == 0:
			s[i][j] = (s[i - 1][-1] + a[i][j]) % 2
		else:
			s[i][j] = (s[i][j - 1] + a[i][j]) % 2
s[H - 1][W - 1] = 0
ans = []
for i in range(H):
	for j in range(W):
		if s[i][j]:
			if i % 2 == 0:
				if j != W - 1:
					ans.append([i + 1, j + 1, i + 1, j + 2])
				else:
					ans.append([i + 1, j + 1, i + 2, j + 1])
			elif j != W - 1:
				ans.append([i + 1, W - j, i + 1, W - j - 1])
			else:
				ans.append([i + 1, W - j, i + 2, W - j])
print(len(ans))
for i in range(len(ans)):
	print('{} {} {} {}'.format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))


(H, W) = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
ans = []
for y in range(H):
	for x in range(W - 1):
		if A[y][x] % 2 == 1:
			A[y][x] -= 1
			A[y][x + 1] += 1
			ans.append([y + 1, x + 1, y + 1, x + 2])
for i in range(H - 1):
	if A[i][-1] % 2 == 1:
		A[i][-1] -= 1
		A[i + 1][-1] += 1
		ans.append([i + 1, W, i + 2, W])
print(len(ans))
for i in ans:
	print(*i)


(h, w) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(h)]
ans_num = 0
ans_l = []
for i in range(h):
	for j in range(w):
		if j != w - 1:
			if l[i][j] % 2 == 1:
				l[i][j] -= 1
				l[i][j + 1] += 1
				ans_num += 1
				ans_l.append([i + 1, j + 1, i + 1, j + 1 + 1])
		elif i != h - 1:
			if l[i][j] % 2 == 1:
				l[i][j] -= 1
				l[i + 1][j] += 1
				ans_num += 1
				ans_l.append([i + 1, j + 1, i + 1 + 1, j + 1])
print(ans_num)
for i in ans_l:
	print(*i)


(H, W) = map(int, input().split())
A = []
Ans = []
for i in range(H):
	a = list(map(int, input().split()))
	if i % 2 == 0:
		A += a
	else:
		A += a[::-1]
for i in range(H * W - 1):
	if A[i] % 2 == 1:
		A[i] -= 1
		A[i + 1] += 1
		y1 = i // W + 1
		x1 = i % W + 1 if y1 % 2 == 1 else W - i % W
		y2 = (i + 1) // W + 1
		x2 = (i + 1) % W + 1 if y2 % 2 == 1 else W - (i + 1) % W
		Ans.append([y1, x1, y2, x2])
print(len(Ans))
for ans in Ans:
	print(*ans)


i = lambda : map(int, input().split())
c = lambda x: -x * 2 + 1
(h, w) = i()
l = []
for q in range(h):
	l += list(i())[::c(q % 2)]
o = []
for j in range(w * h - 1):
	if l[j] % 2:
		(a, b) = divmod(j, w)
		(y, m, n) = (a + 1, a % 2, b == w - 1)
		x = [b + 1, w - b][m]
		o += [[y, x, [y, y + 1][n], [x + c(m), x][n]]]
		l[j + 1] += 1
print(len(o))
for p in o:
	print(*p)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
(r, c, dr, dc) = (0, 0, 0, 1)
ret = []
for i in range(h * w - 1):
	if not (0 <= r + dr < h and 0 <= c + dc < w and (a[r + dr][c + dc] >= 0)):
		(dr, dc) = (dc, -dr)
	if a[r][c] % 2 != 0:
		ret.append((r, c, r + dr, c + dc))
		a[r + dr][c + dc] += 1
	a[r][c] = -1
	(r, c) = (r + dr, c + dc)
print(len(ret))
for (r1, c1, r2, c2) in ret:
	print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)


(H, W) = map(int, input().split())
A = []
for h in range(H):
	tmp = list(map(int, input().split()))
	if h % 2 == 0:
		r = range(W)
	else:
		r = range(W)[::-1]
	for w in r:
		A.append((h, w, tmp[w]))
ans = []
for i in range(len(A) - 1):
	if A[i][2] % 2 != 0:
		ans.append((A[i][0] + 1, A[i][1] + 1, A[i + 1][0] + 1, A[i + 1][1] + 1))
		A[i + 1] = (A[i + 1][0], A[i + 1][1], A[i + 1][2] + 1)
print(len(ans))
for x in ans:
	print(*x)


(H, W) = map(int, input().split())
a = list((list(map(int, input().split())) for i in range(H)))
ans = []
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2 == 1:
			ans.append([i + 1, j + 1, i + 1, j + 2])
			a[i][j + 1] += 1
for i in range(H - 1):
	if a[i][W - 1] % 2 == 1:
		ans.append([i + 1, W, i + 2, W])
		a[i + 1][W - 1] += 1
print(len(ans))
for (a, b, c, d) in ans:
	print(a, b, c, d)


from collections import deque
icase = 0
if icase == 0:
	(h, w) = list(map(int, input().split()))
	a = [[0] * w for i in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().split()))
elif icase == 1:
	(h, w) = (2, 3)
	a = [[1, 2, 3], [0, 1, 1]]
elif icase == 2:
	(h, w) = (3, 2)
	a = [[1, 0], [2, 1], [1, 0]]
elif icase == 3:
	(h, w) = (1, 5)
	a = [[9, 9, 9, 9, 9]]
astat = 0
im = -1
jm = -1
q = deque()
for i in range(h):
	if i % 2 == 0:
		wst = 0
		wed = w
		wpt = 1
	else:
		wst = w - 1
		wed = -1
		wpt = -1
	for j in range(wst, wed, wpt):
		if a[i][j] % 2 == 1 and astat == 0:
			astat = 1
		elif a[i][j] % 2 == 1 and astat == 1:
			q.append((im, jm, i, j))
			astat = 0
		elif a[i][j] % 2 == 0 and astat == 0:
			astat = 0
		elif a[i][j] % 2 == 0 and astat == 1:
			astat = 1
			q.append((im, jm, i, j))
		im = i
		jm = j
print(len(q))
for i in range(len(q)):
	(yf, xf, yt, xt) = q.popleft()
	stra = str(yf + 1) + ' ' + str(xf + 1) + ' ' + str(yt + 1) + ' ' + str(xt + 1)
	print(stra)


(H, W) = map(int, input().split())
lst = []
res = []
for _ in range(H):
	S = list(map(int, input().split()))
	lst.append(S)
for i in range(H - 1):
	for j in range(W):
		if lst[i][j] % 2 == 1:
			lst[i][j] -= 1
			lst[i + 1][j] += 1
			res.append([i + 1, j + 1, i + 1 + 1, j + 1])
for j in range(W - 1):
	if lst[H - 1][j] % 2 == 1:
		lst[H - 1][j] -= 1
		lst[H - 1][j + 1] += 1
		res.append([H, j + 1, H, j + 1 + 1])
print(len(res))
for i in range(len(res)):
	print(*res[i])


from math import ceil, floor, factorial, gcd, sqrt, log2, cos, sin, tan, acos, asin, atan, degrees, radians, pi, inf, comb
from itertools import accumulate, groupby, permutations, combinations, product, combinations_with_replacement
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import Queue, LifoQueue, PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(MAP())
(h, w) = MAP()
a = [[0] * (w + 1)]
for i in range(1, h + 1):
	a.append([0] + LIST())
ans = []
flag = False
for i in range(1, h + 1):
	if i % 2 == 1:
		for j in range(1, w + 1):
			if a[i][j] % 2 == 1:
				flag = not flag
			if flag:
				if j < w:
					ans.append([i, j, i, j + 1])
				elif i < h:
					ans.append([i, j, i + 1, j])
	else:
		for j in range(w, 0, -1):
			if a[i][j] % 2 == 1:
				flag = not flag
			if flag:
				if j > 1:
					ans.append([i, j, i, j - 1])
				elif i < h:
					ans.append([i, j, i + 1, j])
print(len(ans))
for x in ans:
	print(*x)


(H, W) = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for _ in range(H)]
ans = []
for h in range(H):
	for w in range(W - 1):
		if A[h][w] % 2 == 1:
			A[h][w + 1] += 1
			ans.append([h + 1, w + 1, h + 1, w + 2])
	if h < H - 1 and A[h][W - 1] % 2 == 1:
		A[h + 1][W - 1] += 1
		ans.append([h + 1, W, h + 2, W])
print(len(ans))
for a in ans:
	print(*a)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	k = list(map(int, input().split()))
	a.append(k)
q = []
for i in range(n):
	for j in range(m):
		if a[i][j] % 2 != 0:
			a[i][j] -= 1
			if j != m - 1:
				a[i][j + 1] += 1
				q.append([i + 1, j + 1, i + 1, j + 1 + 1])
			else:
				try:
					a[i + 1][j] += 1
					q.append([i + 1, j + 1, i + 1 + 1, j + 1])
				except:
					print(len(q))
					for ii in range(len(q)):
						print(*q[ii])
					exit()
print(len(q))
for i in range(len(q)):
	print(*q[i])


(H, W) = map(int, input().split())
HW = [[0] * (W + 1)] + [[0] + list(map(int, input().split())) for i in range(H)]
f = 0
rev = False
lsmove = []
N = 0
i = 1
while i <= H:
	if rev == False:
		for j in range(1, W + 1):
			if HW[i][j] % 2 == 0:
				continue
			elif j != W:
				lsmove.append([i, j, i, j + 1])
				HW[i][j + 1] += 1
				N += 1
			elif i != H:
				lsmove.append([i, j, i + 1, j])
				HW[i + 1][j] += 1
				N += 1
		rev = True
		i += 1
		if j == W and i == H + 1:
			break
	if rev == True:
		for j in range(W, 0, -1):
			if HW[i][j] % 2 == 0:
				continue
			elif j != 1:
				lsmove.append([i, j, i, j - 1])
				HW[i][j - 1] += 1
				N += 1
			elif i != H:
				lsmove.append([i, j, i + 1, j])
				HW[i + 1][j] += 1
				N += 1
		rev = False
		i += 1
		if j == 1 and i == H + 1:
			break
print(N)
for i in lsmove:
	print(*i, sep=' ')


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
res = []
d = []
for i in range(H):
	for j in range(W)[::(-1) ** i]:
		d.append([i, j])
for i in range(len(d) - 1):
	y = d[i][0]
	x = d[i][1]
	if a[y][x] % 2:
		a[d[i + 1][0]][d[i + 1][1]] += 1
		a[y][x] -= 1
		res.append([y + 1, x + 1, d[i + 1][0] + 1, d[i + 1][1] + 1])
print(len(res))
for r in res:
	print(*r)


(H, W) = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(H)]
cells = []
for i in range(H):
	if i % 2 == 0:
		for j in range(W):
			cells.append((i, j))
	else:
		for j in range(W - 1, -1, -1):
			cells.append((i, j))
ans = []
for k in range(H * W - 1):
	(i, j) = cells[k]
	if a[i][j] % 2 == 1:
		(ni, nj) = cells[k + 1]
		a[i][j] -= 1
		a[ni][nj] += 1
		ans.append([i + 1, j + 1, ni + 1, nj + 1])
print(len(ans))
for i in range(len(ans)):
	print((ans[i][0], ans[i][1], ans[i][2], ans[i][3]))


(H, W) = map(int, input().split())
a = [None] * H
for i in range(H):
	a[i] = list(map(int, input().split()))
ans = []
for i in range(H):
	for j in range(W):
		if i == H - 1 and j == W - 1:
			continue
		if a[i][j] % 2 == 1:
			if j != W - 1:
				ans.append((i, j, i, j + 1))
				a[i][j + 1] += 1
			else:
				ans.append((i, j, i + 1, j))
				a[i + 1][j] += 1
print(len(ans))
for aa in ans:
	print(*[aaa + 1 for aaa in aa])


(H, W) = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(H)]
l = []
for h in range(H):
	for w in range(W - 1):
		if d[h][w] % 2:
			d[h][w + 1] += 1
			d[h][w] -= 1
			l.append((h + 1, w + 1, h + 1, w + 2))
for h in range(H - 1):
	if d[h][W - 1] % 2:
		d[h][W - 1] -= 1
		d[h + 1][W - 1] += 1
		l.append((h + 1, W, h + 2, W))
print(len(l))
for i in l:
	print(*i)


(H, W) = map(int, input().split())
a = []
N = 0
ans = []
for i in range(H):
	A = list(map(int, input().split()))
	a.append(A)
for i in range(H - 1):
	for j in range(W):
		if a[i][j] % 2 == 1:
			a[i + 1][j] += 1
			ans.append([i + 1, j + 1, i + 2, j + 1])
			N += 1
for j in range(W - 1):
	if a[-1][j] % 2 == 1:
		a[-1][j + 1] += 1
		ans.append([H, j + 1, H, j + 2])
		N += 1
print(N)
for i in ans:
	print(' '.join(map(str, i)))


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
L = []
for i in range(H):
	for j in range(W - 1):
		if A[i][j] % 2 == 1:
			A[i][j] -= 1
			A[i][j + 1] += 1
			L.append((i + 1, j + 1, i + 1, j + 2))
for i in range(H - 1):
	if A[i][W - 1] % 2 == 1:
		A[i][W - 1] -= 1
		A[i + 1][W - 1] += 1
		L.append((i + 1, W, i + 2, W))
print(len(L))
for (y, x, y_, x_) in L:
	print(y, x, y_, x_)


(h, w) = map(int, input().split(' '))
ans = []
aw = []
for y in range(1, h + 1):
	ay = list(map(int, input().split(' ')))
	for x in range(1, w):
		if ay[x - 1] % 2 == 1:
			ans.append((y, x, y, x + 1))
			ay[x] += 1
	aw.append(ay[w - 1])
for y in range(1, h):
	if aw[y - 1] % 2 == 1:
		ans.append((y, w, y + 1, w))
		aw[y] += 1
print(len(ans))
for elm in ans:
	print(elm[0], elm[1], elm[2], elm[3])


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
result = []
for x in range(h):
	for y in range(w):
		if a[x][y] % 2 == 1:
			if y + 1 < w:
				a[x][y + 1] += 1
				result.append([x + 1, y + 1, x + 1, y + 1 + 1])
			elif x + 1 < h:
				a[x + 1][y] += 1
				result.append([x + 1, y + 1, x + 1 + 1, y + 1])
print(len(result))
for i in result:
	print(*i)


(h, w) = map(int, input().split())
raw = []
n = 0
ans = []
for j in range(h):
	tmp = list(map(lambda x: int(x) % 2, input().split()))
	for i in range(w - 1):
		tmp[i + 1] ^= tmp[i]
		n += tmp[i]
		if tmp[i] == 1:
			ans.append([j + 1, i + 1, j + 1, i + 2])
	raw.append(tmp[-1])
for j in range(h - 1):
	raw[j + 1] ^= raw[j]
	n += raw[j]
	if raw[j] == 1:
		ans.append([j + 1, w, j + 2, w])
print(n)
for k in range(n):
	print(' '.join(list(map(str, ans[k]))))


(H, W) = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(H)]
data = []
cnt = 0
for i in range(H - 1):
	for j in range(W):
		if s[i][j] % 2 != 0:
			cnt += 1
			s[i + 1][j] += 1
			data.append([i + 1, j + 1, i + 2, j + 1])
for j in range(W - 1):
	if s[H - 1][j] % 2 != 0:
		cnt += 1
		s[H - 1][j + 1] += 1
		data.append([H, j + 1, H, j + 2])
print(cnt)
for i in data:
	print(i[0], i[1], i[2], i[3])


inpl = lambda : list(map(int, input().split()))
(H, W) = inpl()
A = []
for _ in range(H):
	A.append(inpl())

def pos(n):
	(q, m) = divmod(n, W)
	if q % 2:
		m = W - 1 - m
	return (q, m)
ans = []
f = 0
(hn, wn) = (0, 0)
for n in range(H * W - 1):
	(h, w) = (hn, wn)
	(hn, wn) = pos(n + 1)
	if (f + A[h][w]) % 2:
		ans.append([h + 1, w + 1, hn + 1, wn + 1])
		f = 1
	else:
		f = 0
print(len(ans))
for rec in ans:
	print(rec[0], rec[1], rec[2], rec[3])


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
arr = []
for i in range(H - 1):
	for j in range(W):
		if A[i][j] % 2 != 0:
			A[i + 1][j] += 1
			arr.append([i + 1, j + 1, i + 2, j + 1])
for k in range(W - 1):
	if A[H - 1][k] % 2 != 0:
		A[H - 1][k + 1] += 1
		arr.append([H, k + 1, H, k + 2])
N = len(arr)
print(N)
for i in range(N):
	print(arr[i][0], arr[i][1], arr[i][2], arr[i][3])


(H, W) = map(int, input().split())
lsHW = []
for i in range(H):
	if i % 2 == 0:
		lsHW += list(map(int, input().split()))
	if i % 2 == 1:
		lsHW += reversed(list(map(int, input().split())))
N = 0
lsmove = []
for i in range(H * W - 1):
	if lsHW[i] % 2 == 0:
		continue
	else:
		y1 = i // W + 1
		y2 = (i + 1) // W + 1
		if i // W % 2 == 0:
			x1 = i % W + 1
		if i // W % 2 == 1:
			x1 = W - i % W
		if (i + 1) // W % 2 == 0:
			x2 = (i + 1) % W + 1
		if (i + 1) // W % 2 == 1:
			x2 = W - (i + 1) % W
		N += 1
		lsHW[i + 1] += 1
		lsmove.append([y1, x1, y2, x2])
print(N)
for i in lsmove:
	print(*i, sep=' ')


(t, *a) = open(0)
(h, w) = map(int, t.split())
a = [list(map(int, x.split())) for x in a]
ret = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2:
			a[i][j + 1] += 1
			ret += [(i + 1, j + 1, i + 1, j + 2)]
for i in range(h - 1):
	if a[i][-1] % 2:
		a[i + 1][-1] += 1
		ret += [(i + 1, w, i + 2, w)]
print(len(ret))
for (a, b, c, d) in ret:
	print(a, b, c, d)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
z = []
m = []
for i in range(h):
	for j in range(w)[::(-1) ** i]:
		m.append((i, j))
for i in range(h * w - 1):
	(x, y) = m[i]
	if a[x][y] % 2:
		(X, Y) = m[i + 1]
		z.append([x + 1, y + 1, X + 1, Y + 1])
		a[X][Y] += 1
print(len(z))
for i in z:
	print(*i)


from sys import stdin

def main():
	readline = stdin.readline
	(h, w) = map(int, readline().split())
	a = [list(map(int, readline().split())) for _ in range(h)]
	i = 0
	j = 0
	n = 0
	ans = []
	while True:
		if i % 2 == 0:
			if j < w - 1:
				if a[i][j] % 2 == 1:
					n += 1
					ans.append([i + 1, j + 1, i + 1, j + 2])
					a[i][j + 1] += 1
				j += 1
			elif j == w - 1:
				if i < h - 1:
					if a[i][j] % 2 == 1:
						n += 1
						ans.append([i + 1, j + 1, i + 2, j + 1])
						a[i + 1][j] += 1
					i += 1
				else:
					break
		elif j > 0:
			if a[i][j] % 2 == 1:
				n += 1
				ans.append([i + 1, j + 1, i + 1, j])
				a[i][j - 1] += 1
			j -= 1
		elif j == 0:
			if i < h - 1:
				if a[i][j] % 2 == 1:
					n += 1
					ans.append([i + 1, j + 1, i + 2, j + 1])
					a[i + 1][j] += 1
				i += 1
			else:
				break
	print(n)
	for i in range(n):
		print(*ans[i])

def __starting_point():
	main()
__starting_point()


f = lambda : [*map(int, input().split())]
(h, w) = f()
g = [f() for _ in range(h)]
tx = ty = 0
a = []
for y in range(h):
	for x in range(w):
		if y % 2:
			if tx:
				(nx, ny) = (tx - 1, ty)
			else:
				(nx, ny) = (tx, ty + 1)
		elif tx < w - 1:
			(nx, ny) = (tx + 1, ty)
		else:
			(nx, ny) = (tx, ty + 1)
		if ny == h:
			break
		if g[ty][tx] % 2:
			g[ty][tx] -= 1
			g[ny][nx] += 1
			a += [[ty + 1, tx + 1, ny + 1, nx + 1]]
		(ty, tx) = (ny, nx)
	if ny == h:
		break
print(len(a))
for l in a:
	print(*l)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
ans = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			a[i][j] -= 1
			a[i][j + 1] += 1
			ans.append((i + 1, j + 1, i + 1, j + 2))
for i in range(h - 1):
	if a[i][w - 1] % 2 == 1:
		a[i][w - 1] -= 1
		a[i + 1][w - 1] += 1
		ans.append((i + 1, w, i + 2, w))
print(len(ans))
for (a, b, c, d) in ans:
	print(a, b, c, d)


(H, W) = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(H)]
out = []
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2:
			out.append([i + 1, j + 1, i + 1, j + 2])
			a[i][j] -= 1
			a[i][j + 1] += 1
for i in range(H - 1):
	if a[i][-1] % 2:
		out.append([i + 1, W, i + 2, W])
		a[i][W - 1] -= 1
		a[i + 1][W - 1] += 1
print(len(out))
for sub in out:
	print(' '.join(map(str, sub)))


(H, W) = map(int, input().split())
A = []
Q = []
for _ in range(H):
	A.append(list(map(int, input().split())))
for h in range(H - 1):
	for w in range(W):
		if A[h][w] % 2 == 1:
			Q.append([h + 1, w + 1, h + 2, w + 1])
			A[h + 1][w] += 1
for w in range(W - 1):
	if A[H - 1][w] % 2 == 1:
		Q.append([H, w + 1, H, w + 2])
		A[H - 1][w + 1] += 1
print(len(Q))
for i in range(len(Q)):
	print(*Q[i])


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in [0] * h]
res = []
for i in range(h):
	for j in range(w - 1):
		if a[i][j] % 2 == 1:
			res.append((i + 1, j + 1, i + 1, j + 2))
			a[i][j + 1] += 1
for i in range(h - 1):
	if a[i][-1] % 2 == 1:
		res.append((i + 1, w, i + 2, w))
		a[i + 1][-1] += 1
print(len(res))
for (r1, r2, r3, r4) in res:
	print(r1, r2, r3, r4)


(H, W) = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(H)]
ans = []
for (i, al) in enumerate(A):
	for j in range(W - 1):
		if al[j] & 1:
			A[i][j] -= 1
			A[i][j + 1] += 1
			ans.append((i + 1, j + 1, i + 1, j + 2))
for (i, al) in enumerate(A[:-1]):
	if al[-1] & 1:
		A[i][-1] -= 1
		A[i + 1][-1] += 1
		ans.append((i + 1, W, i + 2, W))
print(len(ans))
for a in ans:
	print(*a)


(h, w) = map(int, input().split())
a = []
for i in range(h):
	b = list(map(int, input().split()))
	a.append(b)
ans = []
for i in range(h - 1):
	for j in range(w):
		if a[i][j] % 2 == 1:
			a[i + 1][j] += 1
			x = i + 1
			y = j + 1
			ans.append([x, y, x + 1, y])
for i in range(w - 1):
	if a[h - 1][i] % 2 == 1:
		a[h - 1][i + 1] += 1
		x = h
		y = i + 1
		ans.append([x, y, x, y + 1])
print(len(ans))
for i in ans:
	print(*i)


(H, W) = map(int, input().split())
G = [list(map(int, input().split())) for _ in range(H)]
ans = []
for h in range(H - 1):
	for w in range(W):
		if G[h][w] % 2:
			ans.append([h + 1, w + 1, h + 2, w + 1])
			G[h][w] -= 1
			G[h + 1][w] += 1
for w in range(W - 1):
	if G[H - 1][w] % 2:
		ans.append([H, w + 1, H, w + 2])
		G[H - 1][w] -= 1
		G[H - 1][w + 1] += 1
print(len(ans))
for row in ans:
	print(*row)


import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
(H, W) = map(int, input().split())
a = [[0] for f in range(H)]
ans = []
for i in range(H):
	a[i] = list(map(int, input().split()))
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2 == 1:
			ans.append([i + 1, j + 1, i + 1, j + 2])
			a[i][j + 1] += 1
for i in range(H - 1):
	if a[i][W - 1] % 2 == 1:
		ans.append([i + 1, W, i + 2, W])
		a[i + 1][W - 1] += 1
print(len(ans))
for i in ans:
	print(*i)


(H, W) = map(int, input().split())
D = []
res = []
for _ in range(H):
	D.append(list(map(int, input().split())))
for i in range(H - 1):
	for j in range(W):
		if D[i][j] % 2:
			D[i + 1][j] += 1
			res.append((i + 1, j + 1, i + 2, j + 1))
for j in range(W - 1):
	if D[H - 1][j] % 2:
		D[H - 1][j + 1] += 1
		res.append((H, j + 1, H, j + 2))
print(len(res))
for (i, j, k, l) in res:
	print(i, j, k, l)


(h, w) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(h)]
ans = []
for i in range(h):
	for j in range(w - 1):
		if arr[i][j] % 2 == 1:
			arr[i][j] -= 1
			arr[i][j + 1] += 1
			ans.append([i + 1, j + 1, i + 1, j + 2])
for i in range(h - 1):
	if arr[i][w - 1] % 2 == 1:
		arr[i][w - 1] -= 1
		arr[i + 1][w - 1] += 1
		ans.append([i + 1, w, i + 2, w])
print(len(ans))
for x in ans:
	print(*x)


(H, W) = [int(a) for a in input().split(' ')]
tab = [[int(a) for a in input().split(' ')] for i in range(H)]
ans = []
moving = False
(i, j) = (0, 0)
dx = 1
while i < H and j < W:
	moving = not moving if tab[i][j] % 2 == 1 else moving
	(ni, nj) = (i, j)
	if dx > 0 and j == W - 1 or (dx < 0 and j == 0):
		ni = i + 1
		dx *= -1
	else:
		nj = j + dx
	if moving and ni < H and (nj < W):
		ans.append([i + 1, j + 1, ni + 1, nj + 1])
	(i, j) = (ni, nj)
print(len(ans))
for row in ans:
	print(' '.join([str(x) for x in row]))


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
n = 0
ans = []
for i in range(h):
	for j in range(w):
		if a[i][j] % 2 == 0:
			continue
		if j < w - 1:
			a[i][j] -= 1
			a[i][j + 1] += 1
			n += 1
			ans.append([i + 1, j + 1, i + 1, j + 2])
		elif i < h - 1:
			a[i][j] -= 1
			a[i + 1][j] += 1
			n += 1
			ans.append([i + 1, j + 1, i + 2, j + 1])
print(n)
for i in ans:
	print(*i)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
l = []
for y in range(H):
	l += [(x, y) for x in list(range(W))[::-1 if y % 2 else 1]]
p = []
for (i, (x, y)) in enumerate(l[:-1]):
	if A[y][x] % 2 == 0:
		continue
	(nx, ny) = l[i + 1]
	p.append((x + 1, y + 1, nx + 1, ny + 1))
	A[y][x] -= 1
	A[ny][nx] += 1
print(len(p))
[print(*p_i[::-1]) for p_i in p]


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
(h, w) = map(int, input().split(' '))
a = [list(map(int, input().split(' '))) for i in range(h)]
l = []
for r in range(h):
	for c in range(w):
		if a[r][c] % 2:
			if c + 1 < w:
				l.append([r, c, r, c + 1])
				a[r][c + 1] += 1
			elif r + 1 < h:
				l.append([r, c, r + 1, c])
				a[r + 1][c] += 1
print(len(l))
for i in l:
	print(i[0] + 1, i[1] + 1, i[2] + 1, i[3] + 1)


(H, W) = map(int, input().split())
map_arr = []
ans = []
cnt = 0
pos = 0
for i in range(H):
	map_arr.extend([[i + 1, idx + 1, num] for (idx, num) in enumerate(list(map(int, input().split())))][::(-1) ** i])
for (x, y, num) in map_arr[:-1]:
	if num % 2 == 1:
		cnt += 1
		map_arr[pos + 1][2] += 1
		ans.append([map_arr[pos][0], map_arr[pos][1], map_arr[pos + 1][0], map_arr[pos + 1][1]])
	pos += 1
print(cnt)
for (x, y, nx, ny) in ans:
	print(x, y, nx, ny)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for k in range(H)]
N = 0
B = []
for h in range(H):
	for w in range(W - 1):
		if A[h][w] % 2 == 1:
			N += 1
			B.append([h + 1, w + 1, h + 1, w + 2])
			A[h][w] -= 1
			A[h][w + 1] += 1
for h in range(H - 1):
	if A[h][W - 1] % 2 == 1:
		N += 1
		B.append([h + 1, W, h + 2, W])
		A[h][W - 1] -= 1
		A[h + 1][W - 1] += 1
print(N)
for b in B:
	print(' '.join(map(str, b)))


(h, w) = map(int, input().split())
a = [[0] * w] * h
for i in range(h):
	a[i] = list(map(int, input().split()))
l = []
p = []
for i in range(h):
	if i % 2 == 1:
		for j in reversed(range(w)):
			l.append(a[i][j])
			p.append((i + 1, j + 1))
	else:
		for j in range(w):
			l.append(a[i][j])
			p.append((i + 1, j + 1))
ans = []
i = 0
while i < h * w:
	if l[i] % 2 == 1:
		k = i
		while (k == i or l[k] % 2 == 0) and k < h * w - 1:
			ans.append(p[k] + p[k + 1])
			k += 1
		i = k
	i += 1
print(len(ans))
for i in ans:
	print(*i)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
ans = []
for i in range(h):
	for j in range(w):
		if i == h - 1 and j == w - 1:
			continue
		if a[i][j] % 2 == 0:
			continue
		if j == w - 1:
			a[i + 1][j] += 1
			ans.append((i + 1, j + 1, i + 2, j + 1))
		else:
			a[i][j + 1] += 1
			ans.append((i + 1, j + 1, i + 1, j + 2))
print(len(ans))
for o in ans:
	print(*o)


(H, W) = (int(i) for i in input().split())
A = [[int(i) for i in input().split()] for i in range(H)]
lst = []
for i in range(H - 1):
	for j in range(W):
		if A[i][j] % 2 == 0:
			continue
		else:
			A[i][j] -= 1
			A[i + 1][j] += 1
			lst.append([i + 1, j + 1, i + 2, j + 1])
for j in range(W - 1):
	if A[H - 1][j] % 2 == 1:
		A[H - 1][j] -= 1
		A[H - 1][j + 1] += 1
		lst.append([H, j + 1, H, j + 2])
print(len(lst))
for l in lst:
	print(*l)


(H, W) = map(int, input().split())
A = [[] for i in range(H)]
for i in range(H):
	A[i] = [int(x) % 2 for x in input().split()]
output = []
for i in range(H - 1):
	for j in range(W):
		if A[i][j] == 1:
			output += [[i + 1, j + 1, i + 2, j + 1]]
			A[i + 1][j] = 1 - A[i + 1][j]
for j in range(W - 1):
	if A[H - 1][j] == 1:
		output += [[H, j + 1, H, j + 2]]
		A[H - 1][j + 1] = 1 - A[H - 1][j + 1]
print(len(output))
for o in output:
	print(o[0], o[1], o[2], o[3])


(h, w) = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(h)]
cnt = 0
ans = []
for i in range(h):
	for j in range(w - 1):
		if lst[i][j] % 2 == 1:
			lst[i][j] -= 1
			lst[i][j + 1] += 1
			ans.append([i + 1, j + 1, i + 1, j + 2])
for i in range(h - 1):
	if lst[i][-1] % 2 == 1:
		lst[i][-1] -= 1
		lst[i + 1][-1] += 1
		ans.append([i + 1, w, i + 2, w])
print(len(ans))
for a in ans:
	print(*a)


(H, W) = map(int, input().split())
a = [[int(x) for x in input().split()] for _ in range(H)]
show = False
prev = (-1, -1)
ans = []
for h in range(H):
	for w in range(W) if h % 2 else range(W - 1, -1, -1):
		if show:
			(ph, pw) = prev
			ans.append((ph + 1, pw + 1, h + 1, w + 1))
		if a[h][w] % 2 == 1:
			show = not show
		prev = (h, w)
print(len(ans))
for (a, b, c, d) in ans:
	print(a, b, c, d)


def main():
	(h, w) = map(int, input().split())
	ls = []
	ans = []
	for i in range(0, h):
		ls.append(list(map(int, input().split())))
	for i in range(0, h):
		for j in range(0, w - 1):
			if ls[i][j] % 2 == 1:
				ls[i][j + 1] += 1
				ans.append([i + 1, j + 1, i + 1, j + 2])
	for i in range(h - 1):
		if ls[i][-1] % 2 == 1:
			ls[i + 1][-1] += 1
			ans.append([i + 1, w, i + 2, w])
	print(len(ans))
	for i in ans:
		print(*i)
main()


(H, W) = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(H)]
res = []
for h in range(H):
	for w in range(W - 1):
		if a[h][w] % 2 is not 0:
			res += ['{0} {1} {2} {3}'.format(h + 1, w + 1, h + 1, w + 2)]
			a[h][w + 1] += 1
for h in range(H - 1):
	w = W - 1
	if a[h][w] % 2 is not 0:
		res += ['{0} {1} {2} {3}'.format(h + 1, w + 1, h + 2, w + 1)]
		a[h + 1][w] += 1
print(len(res))
for t in res:
	print(t)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
z = []
for i in range(w):
	if i % 2 == 0:
		for j in range(h):
			z.append([j, i])
	else:
		for j in range(h):
			z.append([h - j - 1, i])
count = 0
ans = []
for (i, (y, x)) in enumerate(z):
	if a[y][x] % 2 != 0 and i < len(z) - 1:
		count += 1
		ans.append(i)
		a[z[i + 1][0]][z[i + 1][1]] += 1
print(count)
for i in ans:
	print(z[i][0] + 1, z[i][1] + 1, z[i + 1][0] + 1, z[i + 1][1] + 1)


(H, W) = map(int, input().split())
a = [0] * H
result = []
for i in range(H):
	a[i] = list(map(int, input().split()))
	for j in range(W - 1):
		if a[i][j] % 2:
			result.append('{} {} {} {}'.format(i + 1, j + 1, i + 1, j + 2))
			a[i][j + 1] += 1
for i in range(H - 1):
	if a[i][-1] % 2:
		result.append('{} {} {} {}'.format(i + 1, W, i + 2, W))
		a[i + 1][-1] += 1
print(len(result))
for i in range(len(result)):
	print(result[i])


(H, W) = map(int, input().split())
B = []
l = []
for y in range(H):
	A = list(map(int, input().split()))
	x = 0
	for x in range(1, W):
		if A[x - 1] % 2:
			l.append((y + 1, x, y + 1, x + 1))
			A[x] += 1
	B.append(A[x])
	if y and B[-2] % 2:
		l.append((y, W, y + 1, W))
		B[y] += 1
print(len(l))
for a in l:
	print(*a)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
B = []
for h in range(H):
	for w in range(W):
		if A[h][w] % 2 == 1:
			if w + 1 < W:
				B.append([h + 1, w + 1, h + 1, w + 2])
				A[h][w + 1] += 1
			elif h + 1 != H:
				B.append([h + 1, w + 1, h + 2, w + 1])
				A[h + 1][w] += 1
print(len(B))
for b in B:
	print(*b)


(H, W) = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(H)]
q = []
for i in range(H):
	if i % 2 == 0:
		for j in range(W):
			q.append([i, j])
	elif i % 2 == 1:
		for j in range(W - 1, -1, -1):
			q.append([i, j])
N = 0
ans_arr = []
for qi in range(len(q)):
	i = q[qi][0]
	j = q[qi][1]
	if a[i][j] % 2 == 0:
		pass
	elif a[i][j] % 2 == 1 and qi != len(q) - 1:
		N += 1
		a[i][j] -= 1
		a[q[qi + 1][0]][q[qi + 1][1]] += 1
		ans_arr.append([i, j, q[qi + 1][0], q[qi + 1][1]])
print(N)
for (x1, x2, x3, x4) in ans_arr:
	print((x1 + 1, x2 + 1, x3 + 1, x4 + 1))


(h, w) = map(int, input().split())
cells = [[c % 2 == 1 for c in map(int, input().split())] for i in range(h)]
command = []
for i in range(h):
	for j in range(w):
		if cells[i][j]:
			if j < w - 1:
				cells[i][j + 1] ^= True
				command.append((i + 1, j + 1, i + 1, j + 2))
			elif i < h - 1:
				cells[i + 1][j] ^= True
				command.append((i + 1, j + 1, i + 2, j + 1))
print(len(command))
for c in command:
	print(*c)


(h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(h)]
moves = [0]
for y in range(h):
	for x in range(w - 1):
		if a[y][x] % 2:
			moves[0] += 1
			moves.append('{} {} {} {}'.format(y + 1, x + 1, y + 1, x + 2))
			a[y][x] -= 1
			a[y][x + 1] += 1
x = w - 1
for y in range(h - 1):
	if a[y][x] % 2:
		moves[0] += 1
		moves.append('{} {} {} {}'.format(y + 1, x + 1, y + 2, x + 1))
		a[y][x] -= 1
		a[y + 1][x] += 1
for x in moves:
	print(x)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = []
idx_list = [(i, j) if i % 2 == 0 else (i, W - j - 1) for i in range(H) for j in range(W)]
for (i, (x, y)) in enumerate(idx_list[:-1]):
	if A[x][y] % 2 == 1:
		A[idx_list[i + 1][0]][idx_list[i + 1][1]] += 1
		ans.append([x, y, idx_list[i + 1][0], idx_list[i + 1][1]])
print(len(ans))
for v in ans:
	print(*[c + 1 for c in v])


(h, w) = map(int, input().split())
m = [list(map(int, input().split())) for i in range(h)]
pre = 0
ans = 0
ret = []
l = [[0, w, 1], [w - 1, -1, -1]]
for i in range(h):
	(a, s, d) = l[i % 2]
	for j in range(a, s, d):
		if (pre + m[i][j]) % 2:
			pre = 1
			(x, y) = (i, j + d) if 0 <= j + d <= w - 1 else (i + 1, j)
			if 0 <= x < h and 0 <= y < w:
				ans += 1
				ret.append([i + 1, j + 1, x + 1, y + 1])
		else:
			pre = 0
print(ans)
for g in range(ans):
	print(*ret[g])


(H, W) = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(H)]
for i in range(H):
	for j in range(W):
		l[i][j] %= 2
sw = 0
ans = []
for i in range(H):
	if i % 2 == 0:
		for j in range(W):
			if sw == 1:
				ans.append((i + 1, j + 1))
			if l[i][j] == 1:
				sw = 1 if sw == 0 else 0
				if sw == 1:
					ans.append((i + 1, j + 1))
				if sw == 0:
					ans.append(0)
	else:
		for j in reversed(range(W)):
			if sw == 1:
				ans.append((i + 1, j + 1))
			if l[i][j] == 1:
				sw = 1 if sw == 0 else 0
				if sw == 1:
					ans.append((i + 1, j + 1))
				if sw == 0:
					ans.append(0)
f_ans = []
for i in range(len(ans) - 1):
	if ans[i] != 0 and ans[i + 1] != 0:
		f_ans.append((*ans[i], *ans[i + 1]))
print(len(f_ans))
for i in f_ans:
	print(*i)


(H, W) = map(int, input().split())
a = []
for i in range(H):
	a.append([int(x) for x in input().split()])
n = 0
ans = []
for y in range(H):
	if y % 2 == 0:
		for x in range(W - 1):
			if a[y][x] & 1:
				a[y][x + 1] += 1
				n += 1
				ans.append('{} {} {} {}'.format(y + 1, x + 1, y + 1, x + 2))
		if y != H - 1 and a[y][W - 1] & 1:
			a[y + 1][W - 1] += 1
			n += 1
			ans.append('{} {} {} {}'.format(y + 1, W, y + 2, W))
	else:
		for x in range(W - 1, 0, -1):
			if a[y][x] & 1:
				a[y][x - 1] += 1
				n += 1
				ans.append('{} {} {} {}'.format(y + 1, x + 1, y + 1, x))
		if y != H - 1 and a[y][0] & 1:
			a[y + 1][0] += 1
			n += 1
			ans.append('{} {} {} {}'.format(y + 1, 1, y + 2, 1))
print(n)
print('\n'.join(ans))


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
N = 0
ans = []
for hi in range(H):
	for wi in range(W - 1):
		if a[hi][wi] % 2 == 1:
			N += 1
			a[hi][wi + 1] += 1
			ans.append((hi + 1, wi + 1, hi + 1, wi + 2))
for hi in range(H - 1):
	if a[hi][-1] % 2 == 1:
		N += 1
		a[hi + 1][-1] += 1
		ans.append((hi + 1, W, hi + 2, W))
print(N)
for (y, x, yp, xp) in ans:
	print(y, x, yp, xp)


(h, w) = map(int, input().split())
A = []
for i in range(h):
	A.append(list(map(int, input().split())))
S = []
for i in range(h):
	for j in range(w - 1):
		if A[i][j] % 2 != 0:
			A[i][j] -= 1
			A[i][j + 1] += 1
			S.append([i + 1, j + 1, i + 1, j + 2])
for i in range(h - 1):
	if A[i][-1] % 2 != 0:
		A[i][-1] -= 1
		A[i + 1][-1] += 1
		S.append([i + 1, w, i + 2, w])
print(len(S))
for s in S:
	print(*s)


(H, W) = [int(s) for s in input().split()]
ls = [[int(s) for s in input().split()] for i in range(H)]
ans = []
for i in range(H):
	for j in range(W - 1):
		if ls[i][j] % 2 == 1:
			ans.append([i + 1, j + 1, i + 1, j + 2])
			ls[i][j + 1] += 1
for i in range(H - 1):
	if ls[i][W - 1] % 2 == 1:
		ans.append([i + 1, W, i + 2, W])
		ls[i + 1][W - 1] += 1
print(len(ans))
for e in ans:
	print(*e)


(H, W) = map(int, input().split())
a = []
for y in range(H):
	a.append(list(map(int, input().split())))
ans = []
for y in range(H - 1):
	for x in range(W):
		if a[y][x] % 2 == 1:
			ans.append((y + 1, x + 1, y + 2, x + 1))
			a[y][x] -= 1
			a[y + 1][x] += 1
y = H - 1
for x in range(W - 1):
	if a[y][x] % 2 == 1:
		ans.append((y + 1, x + 1, y + 1, x + 2))
		a[y][x] -= 1
		a[y][x + 1] += 1
print(len(ans))
for t in ans:
	print(' '.join(map(str, t)))


(h, w) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]
step = []
for i in range(h):
	for j in range(w):
		if i % 2 == 0:
			step.append((i, j))
		else:
			step.append((i, w - j - 1))
ans = []
for ((a, b), (c, d)) in zip(step, step[1:]):
	if A[a][b] % 2 == 1:
		A[c][d] += 1
		ans.append([a + 1, b + 1, c + 1, d + 1])
print(len(ans))
for a in ans:
	print(*a)


def f(i, w):
	p = i % w
	q = i // w
	if q % 2 == 1:
		p = w - 1 - p
	return [q, p]
(h, w) = map(int, input().split())
a = [[]] * h
for i in range(h):
	a[i] = list(map(int, input().split()))
k = 0
s = []
for i in range(h * w - 1):
	if a[f(i, w)[0]][f(i, w)[1]] % 2 == 1:
		k = 1 - k
	if k == 1:
		s += [f(i, w)[0], f(i, w)[1], f(i + 1, w)[0], f(i + 1, w)[1]]
m = len(s) // 4
print(m)
for i in range(m):
	print(s[4 * i] + 1, s[4 * i + 1] + 1, s[4 * i + 2] + 1, s[4 * i + 3] + 1)


(H, W) = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(H)]
ans = []
idx_list = [(i, j) if i % 2 == 0 else (i, W - j - 1) for i in range(H) for j in range(W)]
for (i, (u, v)) in enumerate(idx_list[:-1]):
	if X[u][v] % 2 == 1:
		(x, y) = idx_list[i + 1]
		X[x][y] += 1
		ans.append((u + 1, v + 1, x + 1, y + 1))
print(len(ans))
for t in ans:
	print(*t)


(h, w) = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(h)]
s = []
for i in range(h):
	for j in range(w - 1):
		if m[i][j] & 1:
			s.append('{} {} {} {}'.format(i + 1, j + 1, i + 1, j + 2))
			m[i][j + 1] += 1
for i in range(h - 1):
	if m[i][w - 1] & 1:
		s.append('{} {} {} {}'.format(i + 1, w, i + 2, w))
		m[i + 1][w - 1] += 1
print(len(s))
print('\n'.join(s))


(h, w) = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(h)]
ans = []
for i in range(h):
	for j in range(w):
		if i == h - 1 and j == w - 1:
			pass
		elif j == w - 1 and a[i][j] % 2 == 1:
			a[i + 1][j] += 1
			ans.append((i + 1, j + 1, i + 2, j + 1))
		elif a[i][j] % 2 == 1:
			a[i][j + 1] += 1
			ans.append((i + 1, j + 1, i + 1, j + 2))
print(len(ans))
for e in ans:
	print(*e)


(h, w) = map(int, input().split())
a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(h)]
road = []
for i in range(h):
	for j in list(range(w))[::i % 2 * -2 + 1]:
		road.append((i + 1, j + 1))
answer = []
for (f, t) in zip(road[:-1], road[1:]):
	if a[f[0] - 1][f[1] - 1] % 2:
		answer.append(f + t)
		a[t[0] - 1][t[1] - 1] += 1
print(len(answer))
for ans in answer:
	print(*ans)


(H, W) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
output = []
for i in range(H - 1):
	for j in range(W):
		if a[i][j] % 2 == 1:
			a[i + 1][j] += 1
			output.append((i + 1, j + 1, i + 2, j + 1))
for i in range(W - 1):
	if a[-1][i] % 2 == 1:
		a[-1][i + 1] += 1
		output.append((H, i + 1, H, i + 2))
print(len(output))
for (y, x, ay, ax) in output:
	print(y, x, ay, ax)


(H, W) = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
ans = []
for i in range(H):
	for j in range(W):
		if i == H - 1 and j == W - 1:
			continue
		if i == H - 1:
			if A[i][j] % 2 == 1:
				A[i][j] -= 1
				A[i][j + 1] += 1
				ans.append((i, j, i, j + 1))
		elif A[i][j] % 2 == 1:
			A[i][j] -= 1
			A[i + 1][j] += 1
			ans.append((i, j, i + 1, j))
print(len(ans))
for (i1, j1, i2, j2) in ans:
	print(i1 + 1, j1 + 1, i2 + 1, j2 + 1)


def inpl():
	return list(map(int, input().split()))
(H, W) = inpl()
MAP = [inpl() for i in range(H)]
flag = False
ans = []
for y in range(H):
	if y % 2 == 0:
		xx = range(W)
	else:
		xx = reversed(range(W))
	for x in xx:
		if flag:
			ans.append([by, bx, y, x])
		if MAP[y][x] % 2 == 1:
			flag = not flag
		(bx, by) = (x, y)
print(len(ans))
for (a, zu, nya, n) in ans:
	print(a + 1, zu + 1, nya + 1, n + 1)


(H, W) = [int(i) for i in input().split(' ')]
a = []
for _ in range(H):
	a.append([int(i) for i in input().split(' ')])
sousa = []
for i in range(H):
	for j in range(W - 1):
		if a[i][j] % 2 == 1:
			a[i][j] -= 1
			a[i][j + 1] += 1
			sousa.append([i + 1, j + 1, i + 1, j + 2])
for i in range(H - 1):
	if a[i][-1] % 2 == 1:
		a[i][-1] -= 1
		a[i + 1][-1] += 1
		sousa.append([i + 1, W, i + 2, W])
print(len(sousa))
for s in sousa:
	print(' '.join([str(i) for i in s]))