Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
mapping = [0]*h
for i in range(h):
  mapping[i] = [int(x)%2 for x in input().split()]

ans = []
side = [0]*h
key = 0
for i in range(h):
  k = 0
  for j in range(w-1):
    if mapping[i][j]:
      if k == 0:
        k = 1
        ans.append([i+1, j+1, i+1, j+2])
      else:
        k = 0
    else:
      if k == 1:
        ans.append([i+1, j+1, i+1, j+2])
      else:
        continue
  if (k == 1 and not mapping[i][w-1]) or (k == 0 and mapping[i][w-1]):
    side[i] = 1
    key += 1
      
k = 0
key //= 2
for i in range(h-1):
  if mapping[i][j]:
    if k == 0:
      k = 1
      ans.append([i+1, w, i+2, w])
    else:
      k = 0
  else:
    if k == 1:
      ans.append([i+1, w, i+2, w])
      key -= 1
    else:
      continue 
  if not key:
    break

print(len(ans))
for i in range(len(ans)):
  print(*ans[i])

Fixed submission:
h, w = map(int, input().split())
a = [0]*h
for i in range(h):
  a[i] = [int(x)%2 for x in input().split()]

ans = 0
ans_list = []
key = 0
for i in range(h):
  if i%2 == 0:
    for j in range(w):
      p = a[i][j]
      if key == 0:
        if p == 0:
          pass
        else:
          key = 1
      else:
        if p == 0:
          key = 1
          ans += 1
          if j == 0:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j, i+1, j+1])
        else:
          key = 0
          ans += 1
          if j == 0:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j, i+1, j+1])
        
      
  else:
    for j in range(w-1, -1, -1):
      p = a[i][j]
      if key == 0:
        if p == 0:
          pass
        else:
          key = 1
      else:
        if p == 0:
          key = 1
          ans += 1
          if j == w-1:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j+2, i+1, j+1])
        else:
          key = 0
          ans += 1
          if j == w-1:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j+2, i+1, j+1])

print(ans)
for i in range(ans):
  print(*ans_list[i])

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
mapping = [0]*h
for i in range(h):
  mapping[i] = [int(x)%2 for x in input().split()]

ans = []
side = [0]*h
key = 0
for i in range(h):
  k = 0
  for j in range(w-1):
    if mapping[i][j]:
      if k == 0:
        k = 1
        ans.append([i+1, j+1, i+1, j+2])
      else:
        k = 0
    else:
      if k == 1:
        ans.append([i+1, j+1, i+1, j+2])
      else:
        continue
    if j == w-2 and k == 1:
      side[i] = 1
      key += 1
k = 0
key //= 2
for i in range(h-1):
  if mapping[i][j]:
    if k == 0:
      k = 1
      ans.append([i+1, w, i+2, w])
    else:
      k = 0
  else:
    if k == 1:
      ans.append([i+1, w, i+2, w])
      key -= 1
    else:
      continue 
  if not key:
    break

print(len(ans))
for i in range(len(ans)):
  print(*ans[i])

Fixed submission:
h, w = map(int, input().split())
a = [0]*h
for i in range(h):
  a[i] = [int(x)%2 for x in input().split()]

ans = 0
ans_list = []
key = 0
for i in range(h):
  if i%2 == 0:
    for j in range(w):
      p = a[i][j]
      if key == 0:
        if p == 0:
          pass
        else:
          key = 1
      else:
        if p == 0:
          key = 1
          ans += 1
          if j == 0:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j, i+1, j+1])
        else:
          key = 0
          ans += 1
          if j == 0:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j, i+1, j+1])
        
      
  else:
    for j in range(w-1, -1, -1):
      p = a[i][j]
      if key == 0:
        if p == 0:
          pass
        else:
          key = 1
      else:
        if p == 0:
          key = 1
          ans += 1
          if j == w-1:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j+2, i+1, j+1])
        else:
          key = 0
          ans += 1
          if j == w-1:
            ans_list.append([i, j+1, i+1, j+1])
          else:
            ans_list.append([i+1, j+2, i+1, j+1])

print(ans)
for i in range(ans):
  print(*ans_list[i])