Written by Anonymous
import sys
import math
def checkVoisin(cell: tuple, grid, max: tuple) -> tuple:
pos_x = cell[1]
pos_y = cell[0]
first = (pos_x, pos_y) #if grid[pos_y][pos_x] == '0' else (-1,-1)
right = (pos_x + 1, pos_y) if pos_x + 1 < max[1] and grid[pos_y][pos_x + 1] == '0' else (-1,-1)
down = (pos_x, pos_y + 1) if pos_y + 1 < max[1] and grid[pos_y + 1][0] == '0' else (-1,-1)
return first+right+down
# Don't let the machines win. You are humanity's last hope...
width = int(input()) # the number of cells on the X axis
height = int(input()) # the number of cells on the Y axis
grid = [[0] * width for cell in range(height)]
for i in range(height):
line = input()
for cell in range(len(line)):
grid[i][cell] = line[cell]
for x in range(height):
for y in range(width):
print((x,y), file=sys.stderr, flush=True)
cell = checkVoisin((x,y), grid, (width, height))
print("%i %i %i %i %i %i"%(cell[0],cell[1],cell[2],cell[3],cell[4],cell[5]))
# Write an action using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
# Three coordinates: a node, its right neighbor, its bottom neighbor