def alive_cell(i, j, state):
    alive = 0
    width = len(state[:])
    height = len(state[:][:])
    for row in range((i - 1), (i + 2)):
        for column in range((j - 1), (j + 2)):
            if ((row < 0) or (row >= height)):
                continue
            if ((column < 0) or (column >= width)):
                continue
            if (state[row][column] == 1):
                alive += 1
    alive -= 1
    if ((alive == 2) or (alive == 3)):
        return 1
    else:
        return 0
def alive_cell(i, j, state):
    alive = 0
    width = len(state[:])
    height = len(state[:][:])
    for row in range((i - 1), (i + 2)):
        for column in range((j - 1), (j + 2)):
            if ((row < 0) or (row >= height)):
                continue
            if ((column < 0) or (column >= width)):
                continue
            if (state[row][column] == 1):
                alive += 1
    alive -= 1
    if ((alive == 2) or (alive == 3)):
        return 1
    else:
        return 0