rows = 10
cols = 10

cells = [False] * rows * cols
cells_ = [False] * rows * cols

#for i in [2,13,21,22,23,45,46,55,56]:
#    cells[i] = True

for i in [1,12,20,21,22]:
    cells[i] = True


neighbors = [[-1,-1],
             [0,-1],
             [1,-1],
             [-1,0],
             [1,0],
             [-1,1],
             [0,1],
             [1,1]]

import time
while True:
    time.sleep(.7)
    print()

    for y in range(rows):
        print()
        for x in range(cols):
            i = 10 * y + x
            print(int(cells[i]), end='')

            n = 0
            for xn, yn in neighbors:

                xn = x + xn
                yn = y + yn

                if xn < 0:
                    xn = cols-1
                if xn == cols:
                    xn = 0
                if yn < 0:
                    yn = rows-1
                if yn == rows:
                    yn = 0

                if cells[10 * yn + xn]:
                    n += 1

            if n < 2:
                cells_[i] = False
            elif n == 2:
                cells_[i] = cells[i]
            elif n == 3:
                cells_[i] = True
            else:
                cells_[i] = False

    for i in range(rows * cols):
        cells[i] = cells_[i]