Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())

A=[]
for i in range(h):
    A.append(list(map(int,input().split())))

C=[]
ha=0
s=1
a=0
b=0
for i in range(h*w):
    if A[a][b]%2==1 :
        ha=(ha+1)%2
    if ha==1:
        if b+s<w and b+s>=0 :
            C.append([a,b,a,b+s])
        elif a<h :
            C.append([a,b,a+1,b])
    if ha==0 :
        aa=len(C)

    if b+s<w and b+s>=0 :
        b+=s
    else:
        a+=1
        s = -s

        
print(aa)

for i in range(aa):
    print(str(C[i][0]+1)+" "+str(C[i][1]+1)+" "+str(C[i][2]+1)+" "+str(C[i][3]+1))
    


Fixed submission:
h,w=map(int,input().split())

A=[]
for i in range(h):
    A.append(list(map(int,input().split())))

if h==1 and w==1 :
    print(0)
else:


    aa=0
    C=[]
    ha=0
    s=1
    a=0
    b=0
    for i in range(h*w):
        if A[a][b]%2==1 :
            ha=(ha+1)%2
        if ha==1:
            if b+s<w and b+s>=0 :
                C.append([a,b,a,b+s])
            elif a<h :
                C.append([a,b,a+1,b])
        if ha==0 :
            aa=len(C)

        if b+s<w and b+s>=0 :
            b+=s
        else:
            a+=1
            s = -s

            
    print(aa)

    for i in range(aa):
        print(str(C[i][0]+1)+" "+str(C[i][1]+1)+" "+str(C[i][2]+1)+" "+str(C[i][3]+1))

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())

A=[]
for i in range(h):
    A.append(list(map(int,input().split())))

C=[]
ha=0
s=1
a=0
b=0
for i in range(h*w):
    if A[a][b]%2==1 :
        ha=(ha+1)%2
    if ha==1:
        if b+s<w and b+s>=0 :
            C.append([a,b,a,b+s])
        elif a<h :
            C.append([a,b,a+1,b])
    if ha==0 :
        aa=len(C)

    if b+s<w and b+s>=0 :
        b+=s
    else:
        a+=1
        s = -s

        
print(aa)

for i in range(aa):
    print(str(C[i][0]+1)+" "+str(C[i][1]+1)+" "+str(C[i][2]+1)+" "+str(C[i][3]+1))

    
    


Fixed submission:
h,w=map(int,input().split())

A=[]
for i in range(h):
    A.append(list(map(int,input().split())))

if h==1 and w==1 :
    print(0)
else:


    aa=0
    C=[]
    ha=0
    s=1
    a=0
    b=0
    for i in range(h*w):
        if A[a][b]%2==1 :
            ha=(ha+1)%2
        if ha==1:
            if b+s<w and b+s>=0 :
                C.append([a,b,a,b+s])
            elif a<h :
                C.append([a,b,a+1,b])
        if ha==0 :
            aa=len(C)

        if b+s<w and b+s>=0 :
            b+=s
        else:
            a+=1
            s = -s

            
    print(aa)

    for i in range(aa):
        print(str(C[i][0]+1)+" "+str(C[i][1]+1)+" "+str(C[i][2]+1)+" "+str(C[i][3]+1))

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())

A=[]
for i in range(h):
    A.append(list(map(int,input().split())))

B=[]

for i in range(h):
    for j in range(w):
        if A[i][j]%2==1 :
            B.append([i,j])

C=[]
for i in range(len(B)//2):
    b00=B[2*i][0]
    b01=B[2*i][1]
    b10=B[2*i+1][0]
    b11=B[2*i+1][1]
    
    while b00>b10 :
        C.append([b00,b01,b00-1,b01])
        b00-=1

    while b00<b10 :
        C.append([b00,b01,b00+1,b01])
        b01+=1

    while b01>b11 :
        C.append([b00,b01,b00,b01-1])
        b01-=1

    while b01<b11 :
        C.append([b00,b01,b00,b01+1])
        b01+=1
print(len(C))
for i in range(len(C)):
    print(str(C[i][0]+1)+" "+str(C[i][1]+1)+" "+str(C[i][2]+1)+" "+str(C[i][3]+1))


Fixed submission:
h,w=map(int,input().split())

A=[]
for i in range(h):
    A.append(list(map(int,input().split())))

if h==1 and w==1 :
    print(0)
else:


    aa=0
    C=[]
    ha=0
    s=1
    a=0
    b=0
    for i in range(h*w):
        if A[a][b]%2==1 :
            ha=(ha+1)%2
        if ha==1:
            if b+s<w and b+s>=0 :
                C.append([a,b,a,b+s])
            elif a<h :
                C.append([a,b,a+1,b])
        if ha==0 :
            aa=len(C)

        if b+s<w and b+s>=0 :
            b+=s
        else:
            a+=1
            s = -s

            
    print(aa)

    for i in range(aa):
        print(str(C[i][0]+1)+" "+str(C[i][1]+1)+" "+str(C[i][2]+1)+" "+str(C[i][3]+1))