def countN(x: int, y: int, fld: list) -> int:
    """ Count all alive neighbours """

    mw, mh = len(fld), len(fld[0])
    """ check 3 row elements above, check 2 sides, check 3 row elements below """
    return fld[(x-1) % mw][(y-1)% mh] + fld[x][(y-1)% mh] + fld[(x+1) % mw][(y-1)% mh] +\
        fld[(x-1) % mw][y] + fld[(x+1) % mw][y] +\
        fld[(x-1) % mw][(y+1)% mh] + fld[x][(y+1)% mh] + fld[(x+1) % mw][(y+1)% mh]