def has_path_core(matrix, row, col, rows, cols,
                  string, plen, visited) -> bool:
    """
    When string[plen] == matrix[row][col], we could find whether
    string[plen+1] is in the surroundings of matrix[row][col].

    If not, go back to the string[plen-1]

    Notes
    ------
    The key points are as belows:
    - True: plen == len(string)
    - when matrix[row][col] == string[plen], find next
    - not visited[row][col] for each round
    - if not hasp, back
    """
    if plen == len(string):
        return True
    hasp = False
    if (row >= 0 and col >= 0 and row < rows and col < cols and
            matrix[row][col] == string[plen] and not visited[row][col]):
        visited[row][col] = True
        plen += 1
        hasp = (has_path_core(matrix, row, col-1, rows, cols,
                              string, plen, visited) or
                has_path_core(matrix, row, col+1, rows, cols,
                              string, plen, visited) or
                has_path_core(matrix, row-1, col, rows, cols,
                              string, plen, visited) or
                has_path_core(matrix, row+1, col, rows, cols,
                              string, plen, visited)
                )
        if not hasp:
            plen -= 1
            visited[row][col] = False
    return hasp