Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.

Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times. Given the number of times each light is pressed, you have to print the current state of each light.
The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The *j*-th number in the *i*-th row is the number of times the *j*-th light of the *i*-th row of the grid is pressed.
# Receives matrix and current position as tuple of the form (R,C)
# as input and returns list of tuples with side-adjacents
def get_side_adjacents(matrix, curr_pos):
    m_length = len(matrix[0]) - 1    # Counted from 0
    m_height = len(matrix) - 1       # Counted from 0
    
    # Top left
    if curr_pos[0] == 0 and curr_pos[1] == 0:
        return [(0,1), (1,0)]
    
    # Top right
    elif curr_pos[0] == 0 and curr_pos[1] == m_length:
        return [(0,m_length-1), (1,m_length)]
    
    # bottom left
    elif curr_pos[0] == m_height and curr_pos[1] == 0:
        return [(m_height-1,0), (m_height,1)]
    
    # bottom right
    elif curr_pos[0] == m_height and curr_pos[1] == m_length:
        return [(m_height,m_length-1), (m_height-1, m_length)]
    
    # left corner
    elif curr_pos[1] == 0:
        return [(curr_pos[0]-1, curr_pos[1]), (curr_pos[0] + 1, curr_pos[1]), 
                (curr_pos[0], curr_pos[1] + 1)]
    
    # right corner    
    elif curr_pos[1] == m_length:
        return [(curr_pos[0]+1, curr_pos[1]),(curr_pos[0]-1, curr_pos[1]),
                (curr_pos[0], curr_pos[1]-1)]

    # top corner
    elif curr_pos[0] == 0:
        return [(curr_pos[0], curr_pos[1]-1),(curr_pos[0], curr_pos[1]+1),
                (curr_pos[0]+1, curr_pos[1])]
    
    # bottom corner
    elif curr_pos[0] == m_height:
        return [(curr_pos[0], curr_pos[1]-1),(curr_pos[0], curr_pos[1]+1),
                (curr_pos[0]-1, curr_pos[1])]
    
    # Not on any corner
    else:
        return [(curr_pos[0],curr_pos[1]+1),(curr_pos[0], curr_pos[1]-1),
                (curr_pos[0]+1,curr_pos[1]),(curr_pos[0]-1,curr_pos[1])]


def get_light_state(matrix):
    for i in range(3):
        for j in range(3):
            if matrix[i][j] % 2:
                matrix[i][j] = 0
            else:
                matrix[i][j] = 1
        

matrix = []
for i in range(3):
    inp = input().split()
    inp = [int(x) for x in inp]

    matrix.append(inp)

# Create a deep copy of matrix
matrix_copy = [x[:] for x in matrix]

for i in range(3):
    for j in range(3):
        curr_pos = (i,j)
        adjacents = get_side_adjacents(matrix, curr_pos)

        for adj in adjacents:
            matrix_copy[adj[0]][adj[1]] += matrix[i][j]

# Change number of presses to on/off state
get_light_state(matrix_copy)

for i in range(3):
    curr_line = ""
    for j in range(3):
        curr_line += str(matrix_copy[i][j])
    print(curr_line)
