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).

Difficulty: interview

Starter code:

Solutions:
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
        else:
            if 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()


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):
#        print("i,j:",i,j)
        if a[i][j]%2==1 and astat==0:
            astat=1
#            print("A:",im,jm,i,j)
        elif a[i][j]%2==1 and astat==1:
            q.append((im,jm,i,j))
#            print("B:",im,jm,i,j)
            astat=0
        elif a[i][j]%2==0 and astat==0:
            astat=0
#            print("C:",im,jm,i,j)
        elif a[i][j]%2==0 and astat==1:
            astat=1
            q.append((im,jm,i,j))
#            print("D:",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)    


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
a = [LIST() for _ in range(H)]

cnt = 0
move = []
for i in range(H):
	for j in range(W):
		if i == H-1 and j == W-1:
			print(cnt)
			for x in move:
				print((*x))
			return
		if i%2 == 0:
			if a[i][j]%2 == 1 and j == W-1:
				a[i][j] -= 1
				a[i+1][j] += 1
				cnt += 1
				move.append((i+1, j+1, i+2, j+1))
			elif a[i][j]%2 == 1:
				a[i][j] -= 1
				a[i][j+1] += 1
				cnt += 1
				move.append((i+1, j+1, i+1, j+2))
		else:
			if a[i][W-j-1]%2 == 1 and j == W-1:
				a[i][W-j-1] -= 1
				a[i+1][W-j-1] += 1
				cnt += 1
				move.append((i+1, W-j, i+2, W-j))
			elif a[i][W-j-1]%2 == 1:
				a[i][W-j-1] -= 1
				a[i][W-j-2] += 1
				cnt += 1
				move.append((i+1, W-j, i+1, W-j-1))


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=(' '))

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(*_)

import sys
input = lambda: sys.stdin.readline().rstrip()
 
h,w=list(map(int,input().split()))
a=[]
for _ in range(h):
    a.append(list(map(int,input().split())))
ans = []
flag = 1
for i in range(h):
    if flag:
        for j in range(w):
            if j == w - 1:
                flag ^= 1
                if i != h - 1 and a[i][j] % 2 == 1: 
                    ans.append([i + 1, j + 1, i + 2, j + 1])
                    a[i + 1][j] += 1
            elif a[i][j] % 2 == 1:
                ans.append([i + 1, j + 1, i + 1, j + 2])
                a[i][j + 1] += 1
    else:
        for j in range(w - 1, -1, -1):
            if j == 0:
                flag ^= 1
                if i != h - 1 and a[i][j] % 2 == 1:
                    ans.append([i + 1, j + 1, i + 2, j + 1])
                    a[i + 1][j] += 1
            elif a[i][j] % 2 == 1:
                ans.append([i + 1, j + 1, i + 1, j])
                a[i][j - 1] += 1
print((len(ans)))
for i in ans:
    print((*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
            else:
                if 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
            else:
                if 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=(' '))

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()

#!/usr/bin python3
# -*- coding: utf-8 -*-

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 _ 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
    else:
        if 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 = 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
#print(a)
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])
            else:
                if 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 = 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=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(h)]
th,tw=0,0
mode=0
ans=[]
ope=0
while ope<h*w:
  if mode==0:
    if tw==w-1:
      if a[th][tw]%2==1 and th+1<h:
        a[th][tw]-=1
        a[th+1][tw]+=1
        ans.append([th+1,tw+1,th+2,tw+1])
      th+=1
      mode=1
    else:
      if a[th][tw]%2==1:
        a[th][tw]-=1
        a[th][tw+1]+=1
        ans.append([th+1,tw+1,th+1,tw+2])
      tw+=1
  elif mode==1:
    if tw==0:
      if a[th][tw]%2==1 and th+1<h:
        a[th][tw]-=1
        a[th+1][tw]+=1
        ans.append([th+1,tw+1,th+2,tw+1])
      th+=1
      mode=0
    else:
      if a[th][tw]%2==1:
        a[th][tw]-=1
        a[th][tw-1]+=1
        ans.append([th+1,tw+1,th+1,tw])
      tw-=1
  ope+=1
# print(a)
print((len(ans)))
for aa in ans:
  print((*aa))


h, w = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(h)]
def nxtij(i, j):
    if i & 1 == 0:
        if j < w - 1:
            return i, j + 1
        elif i < h - 1:
            return i + 1, j
        else:
            return None
    else:
        if j > 0:
            return i, j - 1
        elif i < h - 1:
            return i + 1, j
        else:
            return None

def ijgen():
    p = 0, 0
    while p:
        yield p
        p = nxtij(*p)
    return
ans = []
for i, j in ijgen():
    if a[i][j] & 1:
        p = nxtij(i, j)
        if p:
            a[p[0]][p[1]] += 1
            ans.append((i+1, j+1, p[0]+1, p[1]+1))
print((len(ans)))
for a in ans:
    print((*a))


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 = list(map(int, input().split()))
A = []

for i in range(H):
  a = list(map(int, input().split()))
  if i%2:
    a.reverse()
  A.extend(a)  

ans = []
for i in range(H*W-1):
  if A[i]%2:
    ans.append(i)
    A[i+1] += 1

N = len(ans)
print(N)

def move(m):
  y1, x1 = divmod(m, W)
  y2, x2 = divmod(m+1, W)
  y1 += 1
  y2 += 1
  if m//W%2:
    x1 = W - x1
  else:
    x1 += 1
  if (m+1)//W%2:
    x2 = W - x2
  else:
    x2 += 1
  return (y1, x1, y2, x2)

for i in range(N):
  print((*move(ans[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))

import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
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)]

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))
print(*result, sep='\n')


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]))


def main():
    H, W = map(int, input().split())
    field = []
    for _ in range(H):
        line = list(map(int, input().split()))
        field.append(line)
    
    ans = []
    # zig-zag
    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=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)

import sys

input = sys.stdin.readline

def main():
    H, W = list(map(int, input().split()))
    field = []
    odd = []
    for i in range(H):
        tmp = list(map(int, input().split()))
        field.append(tmp)
    
    rote = []
    for h in range(H):
        for j in range(W):
            if h%2 == 1:
                w = W-j-1
            else:
                w = j
            rote.append((h, w))
    
    ans = []
    for i, r in enumerate(rote):
        h, w = r
        if field[h][w] % 2 == 1:
            if i == H*W-1:
                break
            s, t = rote[i+1]
            ans.append((h+1, w+1, s+1, t+1))
            field[h][w] -= 1
            field[s][t] += 1

    print((len(ans)))
    for a in ans:
        print((*a))

def __starting_point():
    main()

__starting_point()

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)))
#print(*result, sep='\n')


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
    else:
      if 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 = []
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]))

# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    n, m = [int(x) for x in input().split()]
    ans = []
    c = 0
    for i in range(n):
        r = [int(x) for x in input().split()]
        for j in range(m):
            if i + 1 == n and j + 1 == m: continue
            if i % 2:
                j = m - j - 1
            r[j] += c
            c = r[j] % 2
            if c:
                x = i + 1
                y = j + 1
                if i % 2:
                    if y == 1:
                        ans.append((x, y, x + 1, y))
                    else:
                        ans.append((x, y, x, y - 1))
                else:
                    if y == m:
                        ans.append((x, y, x + 1, y))
                    else:
                        ans.append((x, y, x, y + 1))
    print((len(ans)))
    for r in ans:
        print((*r))


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


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))

H, W = list(map(int, input().split()))
grid = []
for _ in range(H):
    line = list(map(int, input().split()))
    grid.append(line)
# print(grid)
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])
# print(q)
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)]
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())
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
        else:
            if a%2==0:
                flag = False
            else:
                flag = True
        prev_i = i
        prev_j = j
print(len(ans))
print("\n".join(ans))

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

ans=[]

c=0
for i in range(h):
    if i%2==0:
        for j in range(w):
            if c==0 and a[i][j]%2==1:
                c=1
            if c==2:
                c=0
            if c==1 and j<w-1:
                ans.append([str(i+1),str(j+1),str(i+1),str(j+2)])
                if a[i][j+1]%2==1:
                    c=2
            elif c==1 and j==w-1 and i+1<=h-1:
                ans.append([str(i+1),str(j+1),str(i+2),str(j+1)])
                if a[i+1][j]%2==1:
                    c=2
    if i%2==1:
        for j in range(w):
            if c==0 and a[i][w-1-j]%2==1:
                c=1
            if c==2:
                c=0
            if c==1 and j<w-1:
                ans.append([str(i+1),str(w-j),str(i+1),str(w-j-1)])
                if a[i][w-j-2]%2==1:
                    c=2
            elif c==1 and j==w-1 and i+1<=h-1:
                ans.append([str(i+1),str(w-j),str(i+2),str(w-j)])
                if a[i+1][w-1-j]%2==1:
                    c=2
print((len(ans)))
for i in ans:
    print((' '.join(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 = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(H)]
# print(a)
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])
# print(q)
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))