import numpy as np
h,w = list(map(int, input().split()))
xs = []
for _ in range(h):
    xs.append(list(map(int, input().split())))
#     xs.append(np.random.binomial(10,0.5,w))

def move_yoko(k,x):
    temp = np.where(x[k] == 1)[0]
    ms = []
    if len(temp)%2 == 0:
        for j in range(int(len(temp)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
                ms.append([k,a+i,k,a+1+i])
        x[k] = 0
    else:
        for j in range(int((len(temp)-1)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
                ms.append([k,a+i,k,a+1+i])
        a = temp[-1]
        b = w - 1
        for i in range(b - a):
            ms.append([k,a+i,k,a+1+i])
        x[k] = 0
        x[k,-1] = 1
    return ms,x

def move_tate(k,x):
    temp = np.where(x[:,k] == 1)[0]
    ms = []
    if len(temp)%2 == 0:
        for j in range(int(len(temp)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
#                 ms.append([k,a+i,k,a+1+i])
                ms.append([a+i,k,a+1+i,k])
        x[:,k] = 0
    else:
        for j in range(int((len(temp)-1)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
                ms.append([a+i,k,a+1+i,k])
                
        a = temp[-1]
        b = h - 1
        for i in range(b - a):
            ms.append([a+i,k,a+1+i,k])
        x[:,k] = 0
        x[-1,k] = 1
    return ms,x

x = np.vstack(xs)
x = x%2

mss = []
for k in range(h):
    ms, x = move_yoko(k,x)
    mss += ms
ms, x = move_tate(w-1,x)
mss += ms
ms = mss

import sys
print(len(ms))
for a in ms:
    for k in range(a):
        if k == len(a)-1:
            sys.stdout.write('{}'.format(a[k] + 1))
        else:
            sys.stdout.write('{} '.format(a[k] + 1))
    sys.stdout.write('\n')

### FIXED CODE ###

import numpy as np
h,w = list(map(int, input().split()))
xs = []
for _ in range(h):
    xs.append(list(map(int, input().split())))
#     xs.append(np.random.binomial(10,0.5,w))

def move_yoko(k,x):
    temp = np.where(x[k] == 1)[0]
    ms = []
    if len(temp)%2 == 0:
        for j in range(int(len(temp)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
                ms.append([k,a+i,k,a+1+i])
        x[k] = 0
    else:
        for j in range(int((len(temp)-1)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
                ms.append([k,a+i,k,a+1+i])
        a = temp[-1]
        b = w - 1
        for i in range(b - a):
            ms.append([k,a+i,k,a+1+i])
        x[k] = 0
        x[k,-1] = 1
    return ms,x

def move_tate(k,x):
    temp = np.where(x[:,k] == 1)[0]
    ms = []
    if len(temp)%2 == 0:
        for j in range(int(len(temp)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
#                 ms.append([k,a+i,k,a+1+i])
                ms.append([a+i,k,a+1+i,k])
        x[:,k] = 0
    else:
        for j in range(int((len(temp)-1)/2)):
            a = temp[2*j]
            b = temp[2*j+1]
            for i in range(b - a):
                ms.append([a+i,k,a+1+i,k])
                
        a = temp[-1]
        b = h - 1
        for i in range(b - a):
            ms.append([a+i,k,a+1+i,k])
        x[:,k] = 0
        x[-1,k] = 1
    return ms,x

x = np.vstack(xs)
x = x%2

mss = []
for k in range(h):
    ms, x = move_yoko(k,x)
    mss += ms
ms, x = move_tate(w-1,x)
mss += ms
ms = mss

import sys
print(len(ms))
for a in ms:
    for k in range(len(a)):
        if k == len(a)-1:
            sys.stdout.write('{}'.format(a[k] + 1))
        else:
            sys.stdout.write('{} '.format(a[k] + 1))
    sys.stdout.write('\n')