Buggy python submission (verdict: Runtime Error):
import copy
x,y = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(x)]

def gonext(a,b):
    if a < y-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)
    a, b = gonext(a, b)
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Fixed submission:

import copy
y,x = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(y)]

way = 1
a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)

    if (way == 1 and a < y-1) or (way == -1 and a > 0):
        a += way
    else:
        b += 1
        way = way*(-1)
    if not (a < y and b < x):
        break
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy python submission (verdict: Runtime Error):
import copy
x,y = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(x)]

def gonext(a,b):
    if a < x-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
count = 0
while a < x and b < y:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)
    a, b = gonext(a, b)
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Fixed submission:

import copy
y,x = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(y)]

way = 1
a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)

    if (way == 1 and a < y-1) or (way == -1 and a > 0):
        a += way
    else:
        b += 1
        way = way*(-1)
    if not (a < y and b < x):
        break
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
x,y = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(x)]

def gonext(a,b):
    if a < x-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
visited = [[-1, -1], [-1, -1]]
stac = 0

count = 0
final = []
while a < x and b < y:
    now = Z[a][b]
    if now % 2 == 0:
        a,b = gonext(a,b)
    else:
        stac += 1
        if stac < 2:
            visited[0] = [a,b]
            a,b = gonext(a,b)
        else:
            visited[1] = [a,b]
            l0, l1 = visited
            
            while not l0 == l1:
                for i in range(2):
                    if l1[i] - l0[i] > 0:
                        l0_copy = copy.deepcopy(l0)
                        l0[i] += 1
                        for j in range(2):
                            l0_copy.append(l0[j])
                        count += 1
                        final.append(l0_copy)
            stac = 0
            a, b = gonext(a, b)
            ans.append(visited)
            visited = [[-1, -1], [-1, -1]]

print(count)
for i in final:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))


Fixed submission:

import copy
y,x = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(y)]

way = 1
a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)

    if (way == 1 and a < y-1) or (way == -1 and a > 0):
        a += way
    else:
        b += 1
        way = way*(-1)
    if not (a < y and b < x):
        break
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy python submission (verdict: Runtime Error):
def gonext(a,b):
    if a < x-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
visited = [[-1, -1], [-1, -1]]
stac = 0

count = 0
final = []
while a < x and b < y:
    now = Z[a][b]
    if now % 2 == 0:
        a,b = gonext(a,b)
    else:
        stac += 1
        if stac < 2:
            visited[0] = [a,b]
            a,b = gonext(a,b)
        else:
            visited[1] = [a,b]

            l0, l1 = visited
            while not l0 == l1:
                for i in range(2):
                    if l1[i] - l0[i] > 0:
                        l0_copy = copy.deepcopy(l0)
                        l0[i] += 1
                        for j in range(2):
                            l0_copy.append(l0[j])
                        count += 1
                        final.append(l0_copy)

            stac = 0
            a, b = gonext(a, b)
            ans.append(visited)
            visited = [[-1, -1], [-1, -1]]

print(count)
for i in final:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Fixed submission:

import copy
y,x = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(y)]

way = 1
a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)

    if (way == 1 and a < y-1) or (way == -1 and a > 0):
        a += way
    else:
        b += 1
        way = way*(-1)
    if not (a < y and b < x):
        break
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
x,y = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(x)]

def gonext(a,b):
    if a < x-1:
        a += 1
    else:
        b += 1
        a = 0
    return(a,b)

a, b = 0, 0
ans = []
visited = [[-1, -1], [-1, -1]]
stac = 0

while a < x and b < y:
    now = Z[a][b]
    if now % 2 == 0:
        a,b = gonext(a,b)
    else:
        stac += 1
        if stac < 2:
            visited[0] = [a,b]
            a,b = gonext(a,b)
        else:
            visited[1] = [a,b]
            stac = 0
            a, b = gonext(a, b)
            ans.append(visited)
            visited = [[-1, -1], [-1, -1]]

count = 0
final = []
for lis in ans:
    l0, l1 = lis
    while not l0 == l1:
        for i in range(2):
            if l1[i] - l0[i] > 0:
                l0_copy = copy.deepcopy(l0)
                l0[i] += 1
                for j in range(2):
                    l0_copy.append(l0[j])
                count += 1
                final.append(l0_copy)

print(count)
for i in final:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))

Fixed submission:

import copy
y,x = list(map(int, input().split()))
Z = [list(map(int, input().split())) for _ in range(y)]

way = 1
a, b = 0, 0
ans = []
count = 0
while a < y and b < x:
    now = Z[a][b]
    a_copy= copy.deepcopy(a)
    b_copy = copy.deepcopy(b)

    if (way == 1 and a < y-1) or (way == -1 and a > 0):
        a += way
    else:
        b += 1
        way = way*(-1)
    if not (a < y and b < x):
        break
    if now % 2 == 1:
        Z[a][b] += 1
        ans.append([a_copy, b_copy, a, b])
        count += 1

print(count)
for i in ans:
    k = [j+1 for j in i]
    print(" ".join(list(map(str, k))))