def expand(x, y, cals, shown, length, width):
    """
    Expand empty position with no bombs surrounded
    :param x: horizontal position
    :param y: vertical position
    :param cals: matrix of numbers
    :param shown: list of positions shown
    :param length: length of the board
    :param width: width of the board
    :return: modified list of positions shown
    """
    for m in (x - 1, x, x + 1):
        for n in (y - 1, y, y + 1):
            if 0 <= m < length and 0 <= n < width:
                if (m != x or n != y) and (m, n) not in shown:
                    shown.append((m, n))
                    if cals[m][n] == 0:
                        expand(m, n, cals, shown, length, width)
    return shown